Home Navigationspfeil Tutorial Firebird Lazarus Zeos II


Tutorial Firebird Lazarus Zeos II

Hier ist die deutsche Version

This tutorial is fully programmed and can be downloaded. It is now working on the documentation and I would say the documentation has Release 1.0 Alpha 1 ;-). The program for the tutorial is available under the menu item Downloads Tutorials. The content in the program directories will not be changed for a long time, the texts linked online will be adapted by users depending on the questions. The English texts are expected to be available sometime in November. The program is Windows (file handling is only useable in Windows) and Firebird affine, but it should be adaptable to other operating systems with little effort. SQL Lite should be able to run in a few simple steps - Protocol and SQL customization are probably necessary. The protocol can be set in the settings. Maybe I'll be building a compiler switch by the end of the year. Currently I do not have the time.

The tutorial assumes that the basic handling of Lazarus, components and their properties (properties) and events has already been learned. There are many links in the documentation for dealing with SQL and Firebird.

The documentation is available in threefold form and can be accessed via buttons, which are located on the individual pages.

Loads a RTF file with your default editor. This is stored in the directory RTF. It contains this text, which is editable. This is to serve as you experiment with the tutorial that you can take notes.

Load the website with this text. This will probably be updated from time to time, depending on the questions of the users of this tutorial. In this way, a current version of the description is always available.

Will contain this text in PDF format to have it available even when offline.

The program is freeware, which means it can be used freely.

The components of the database with which we will deal:

  • ZConnection
  • ZSQLProcessor
  • ZSQLMonitor
  • ZQuery
  • ZUpdateSQL
  • DataSource

I've tested the ZSequence component, but apparently you do not need ZSequence for Firebird 3 and 4 anymore. The counting up of the table rows works without wonderful. If ZSequence is used, the counter is incremented with a 2-jump. So there are still some components left, which I would like to mention here briefly, since these no longer occur in the tutorial.

  • ZReadOnlyQuery
  • Ztable
  • ZConnectionGroup
  • ZGroupedConnection
  • ZStoredProc
  • ZSQLMetadata
  • ZIBEventalerter
  • ZPGEventalerter

Works in principle like ZQuery, but the data can not be edited. The result provides only data for reading.

Like ZQuery, but ZTable delivers all the data of the table from the server to the program and thus loads the traffic or the database server tremendously. If already used, then only for tables with a small amount of data such as configuration data or the like. I think one reason that ZTable exists is its compatibility with Delphi's BDE.

ZConnectionGroup & ZGroupedConnection
These two components are needed to make multiple connections (multiple databases) to the same server without constantly filling the connection parameters.

With ZStoredProc, stored procedures can be executed in a database. There are 2 types of stored procedures with or without result set. ZStoredProc works similar to the StoredProc of Delphi's BDE.

ZSQLMetadata is a special TDataSet component that allows to access the metadata of a database.

This component is specially designed for Firebird or Interbase. This component can intercept events (Event Alert) triggered by procedures stored in the database. This could be a lower stock quantity or something similar.

Corresponds to ZIBEventalerter, but for the database Postgres.

Other components and procedures and functions used

In addition to the Zeos components, almost all features used are installed in the default installation of Lazarus 2. The TFileSearch component is not installed and can be installed via Package-> Install Installed Packages ... (filefindlaz) and appears on the component palette under "Examples".

OpenUrl and OpenDocument require the unit LCLIntf.

TProcess requires the Unit Process.

LemIniRead, LemIniWrite require the unit lemroutines, attached to the project.

All units are present, they only need to be listed in the uses list.

In the program itself, some passages have been executed less "elegantly" and others "more elegantly". I left it that way to show the differences. I will occasionally give a hint here in the documentation. The internal documentation is written in German and English.

The individual lessons are housed in different tabs. Here is a brief overview:

Contains the obligatory statement that the program is freeware, that it is intended for educational purposes and that no liability is assumed for the application. As well as an indication of Turbobird.

This part shows how to connect further queries from a non-editable query via 2 tables which are then editable. How to edit the database fields Properties directly over / in the components ZQuery and in the DBGrid. In all other examples, most things are done in the program code.

The result sets of different queries are displayed as well as the table and field names. This page is meant to experiment with SQL commands for data manipulation.

Shows the result set of the combination of two tables which are not editable as known. By using ZUpdateSQL fields can be edited.

A classic combination of two tables is presented here. This part of the program also contains an explanation of the automatic numbering of data records.

SQL Commands
This is about issuing SQL commands without result set. The work with SetTerm by TZConnection is also housed here.

Create DatabaseThe program used demodatabase is here created. The necessary SQL commands are presented. A database of contents or an "empty" database can be created without any definitions for experimental purposes. With "Create database", the database can always be returned to its original state in a comfortable way.

The parameters required for creating and operating the database are recorded here. In addition, you can display the set parameter in a window, as the Propertyliste of TZConnection would look like with it.

Contains links to various pages that may be helpful when working with the program. The last button is for online help.

The last Lazarus 2.x.x Version is available:
Download Lazarus 2.x.x

Zeos 7.3 Beta you can get here:
At the top reight click Download Snapshot Zeos 7.3

Firebird 4.0 Beta1 you can downlaod here:
Firebird 4.0 RCx

On the Webseite wiki.freepascal.org/Category:Tutorials/de you will also find links to tutorials for Lazarus, Zeos and Firebird.

General notes about the source code

A few hints for an easier to maintain and maintain source code:

One of the most important things is self-explanatory source code (the variables, though they are a bit longer, will advertise so far so you always know what variable you're working). Also, a lot of internal documentation in the code, some unnecessary documentation is better than too little documentation If no comments were included in the tutorial - it would certainly be difficult to read in parts ...

Second, as few global variables as possible. The global variables that I have used here would also have been well placed in parameters of the procedures and functions.

Starting at line 1106, 10 Speedbutton clicks with 5 procedures are programmed. If you took the name and the tags for distinction, it would have been possible with a single procedure. You can see how to do it better starting at lines 2297,  2280 and 2363. This solution also shows what the property "tag" can be used efficiently for.

The file handling is based on Windows. Here with a few handles on e.g. Linux customizable - in Linux the separator is between path and file "/", in Windows "\". With a constant as a default, this would be easy to customize throughout the program without having to manually adjust each individual program location.

These are some striking examples of how to make source code easy to maintain and understand.


© CMBasic.de