Zeos tutorial/es

From Free Pascal wiki
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) português (pt) русский (ru) 中文(中国大陆)‎ (zh_CN)

Overview

This tutorial is about getting, installing and using Zeoslib with Lazarus and FPC.

The Zeos team has recently made a new forum. Please visit the new forum for more information about ZeosLib and to ask/answer questions about using Zeos and report bugs. The new forum can be found here Forum for ZeosLib.

Getting Zeos

Zeos has recently been ported to Lazarus and there are no releases yet that officially support it but you can easily get it from SVN if you follow these steps:

Windows

Linux/BSD

  • get a SVN client (esvn, kdesvn, etc.)
  • create zeosdbo directory, go in that directory and do
  • svn checkout svn://firmos.at/zeos

Instalando los componentes

This is a tricky part so you should have a little patience and read this part carefully.

  • Make sure you have the latest Lazarus snapshot and the at least FPC 2.0.3 not older than 6th March 2006.
  • Comenzar una instancia de Lazarus.
  1. Pulsar en Paquete/Abrir archivo de paquete (.lpk) desde el menú principal.
  2. Ve a zeosdbo_rework\packages\lazarus\ y abre zcomponent.lpk
  3. Presiona [Compile] solamente si no necesitas instalar los componentes en el IDE.
  4. Presiona [Install]
  5. Pregunta si necesitas recompilar Lazarus.
  • Responde [SI] esta vez.
  • Espera a que la compilación termine, LWait until compilation ends, Lazarus debería reiniciarse después de esto.
  • Si todo está bien se debería ver la solapa [Zeos Access] en la paleta de componentes.

Zeos Components.png

Si se presenta el error "Cannot find unit ZClasses" o algo similar, entonces hay que chequear cuidadósamente como están escritos los nombres de fichero (en cuanto a mayúsculas/minúsculas) en sus ficheros de código fuente.

  • Incluso si cuadran exactamente, el paquete autogenerado del fichero fuente puede dar lugar a un tipificado incorrecto (mayúsculas/minúsculas) en la claúsula "uses" (Lazarus 0.9.18), i.e.:

<delphi>

 { Este fichero ha sido generado automáticamente por Lazarus. ¡No se debe editar!
   Esta fuente solo se utiliza para compilar e instalar el paquete.
 }
 unit Zcore; 
 interface
 uses
   Zclasses, Zcollections, Zcompatibility, Zexprparser, Zexprtoken, Zexpression, 
   Zfunctions, Zmatchpattern, Zmessages, Zsysutils, Ztokenizer, Zvariables, 
   Zvariant; 
 implementation
 end.           

</delphi>

  • Notice that Lazarus has named the unit ZClasses Zclasses, resulting in a naming conflict. Presumiblemente este es un error en Lazarus, no de los paquetes Zeos. Un camino a seguir para solucionarlo es renombrar todos los ficheros fuente de Zeos a minúsculas.Trawl through each subdirectory under src/ and execute this command in a bash window:
 rename -v 'y/A-Z/a-z/' *
  • Entonces, en Lazarus, reabre el paquete (.lpk) y corrige el nombre de fichero (mayúsculas/minúsculas) seleccionando en "More..."/"Fix Files Case"
  • El paquete debería poderse compilar entonces.

Comments

Currently Zeos CVS for Lazarus has broken packages. Some comments from IgD:

Using a fresh install of Laz 0.9.12 (latest stable version) I was able to install ZeosLib dated 13 Oct 05. First fix the following bugs in ZeosLib:

  • 1. Change ZplainPostgreSql81.pas to ZPlainPostgresSql8x.pas in zplain.lpk
<Item22>
  <Filename Value="../../src/plain/ZPlainPostgreSql81.pas"/>
  <UnitName Value="ZPlainPostgreSql8x"/>
</Item22>

  • 2. Fix the following typos in zdbc.lpk:

a. Remove extra "/" from "build/" (remove the one that is inside the quotes)

<SearchPaths>
  <OtherUnitFiles Value="../../src/dbc/"/>
  <UnitOutputDirectory Value="build/"/>
</SearchPaths>

b. Add missing quote to unitname value

<Item43>
  <Filename Value="../../src/dbc/ZDbcASA.pas"/>
  <UnitName Value="ZDbcASA/>
</Item43>

Now, here are the installation instructions: Ahora, aquí están las instrucciones de instalación:

Antes de la versión 0.9.13 de Lazarus era necesario abrir cada uno de los paquetes de Zeos a través de Paquetes/Abrir Paquete en el siguiente orden:

  1. zcore.lpk
  2. zparsesql.lpk
  3. zplain.lpk
  4. zdbc.lpk

Entonces finalmente abre zcomponent.lpk para compilarlo e instalarlo. 0.9.13 can simply open zcomponent.lpk. The IDE will open the rest automatically.

Nota: los cuatro primeros paquetes solamente necesitan ser compilados y no pueden ser instalados.

--Forest 17:41, 2 Nov 2005 (CET)

  • 3. If you compile and install with sucessfull Zeos, pero Lazarus, después de compilarse, comienza con:

Zeoserror.gif

Entonces se puede hacer:

Dentro del fichero Zeos.Inc reemplazar, en la sección "// Settings for Debug mode": {$R-} a {$R+}

--Junior 19:48, 15 Apr 2006 (GMT)

Hacer la primera aplicación Zeos

  • Drop a ZConnection.
    • Set your User, Password, Host, Port and Protocol (y cualquier otro parámetro que se necesite).
    • Establecer la propiedad "Set Connected" con el valor True.
  • Drop a ZQuery (do not mistake with ZReadOnlyQuery).
    • Set the Connection to your active ZConnection.
    • Set the Sql property to something like SELECT * FROM MyTable
    • Set Active to True.
  • Drop a DataSource from the [Data Access] tab.
    • Set the DataSet to your active ZQuery.
  • Drop a DBGrid from the [Data Controls] tab.
    • Set the Datasource to your DataSource.
    • If all is ok you should now be able to see the records from your table.

Más información sobre como trabajar con Zeos

En los siguientes enlaces se pueden encontrar artículos realmente útiles explicando el uso de Zeos y su uso interno, alguno de los cuales además tratan acerca de pero la mayor parte de las técnicas pueden ser utilizadas también en Lazarus.

some of them   also talk about Delphi specific stuff but mostly the same techniques can be used in Lazarus too.


Por favor completar esto :)

Posibles fallos e incidencias

  1. I have noticed that somethimes when building Lazarus it cannot find some Zeos files, as a quick workaround try this:
    • Use Components/Package Graph from the main menu.
    • Open the ZComponent package.
    • Right Click on the Files item in the list.
    • Choose [Recompile all required].
    • When asked "Re-Compile this and all required packages?" answer [Yes].
    • Recompile Lazarus normally (with packages).

  2. There is a bug in FPC's AnsiStrComp wich causes unreliable PChar comparison, this is obvious when using a DBGrid to edit data, AnsiStrComp('abc', 'abcd') can't detect them as being different but it detects AnsiStrComp('abd', 'abcd') ignoring multiple chars from the second string. This bug was found by Jesusrmx. It will probably be fixed soon, see Bug Report.