Sign in Join
Wiki copytemporary

TPSQL/es

Deutsch · English · Español

Acerca de

TPSQL e un paquete modificado bajo LGPL para Lazarus. Define dos componentes, TPSQLDatabase y TPSQLDataset, permitiendo a las aplicaciones conectar con servidores de bases de datos PostgreSQL en redes que utilizan TCP/IP.

La descarga contiene los ficheros de componentes Pascal, el fichero de paquete para Lazarus y los ficheros de recursos junto con los ficheros de texto que describen la licencia modified-LGPL.

Este componente fué diseñado para su utilización en aplicaciones corriendo bajo plataformas Linux y Win32.

Autor

Antonio d'Avino

Licencia

LGPL modificada (leer COPYING.modifiedLGPL y COPYING.LGPL que se incluyen en el paquete).

Descarga

La última versión estable se puede encontrar en Lazarus CCR Files page o en la página web del autor http://infoconsult.homelinux.net.

Historial de cambios

text
 - ClientEncoding property added to TPSQLDatabase class.
text
 - Some changes to destroy method of TPSQLDatabase/TPSQLDataset for avoiding exception
   when closing IDE/project with components in Active/Connected status.
 - Base path in archived files changed from 'usr/share/lazarus/components/psql' to 'psql'
pascal
 - Executing queries that doesn't return data column now raises an exception.
 - commandQuery function added (see Usage section).
 - beginTransaction/commitTransaction/rollbackTransaction support added (see Usage section).
 - More ClientEncoding entities added.

Dependencias / Requerimientos del sistema

Stado: estable

Issues: Testeado bajo Windows (Win2K) y Linux (Mdk 10.1). Servidor de base de datos: PostgreSQL 8.0.3 (corriendo en ambas plataformas).

Instalación

Nota importante para los usuarios de Win32.

pascal
En caso de experimentar dificultades a la hora de compilar los ficheros Pascal del paquete, puede que se necesite a??adir  la siguiente trayectoria:

 
<some-drive>:<some-path>\lazarus\lcl\units\i386-win32 
(ie: c:\programs\lazarus\lcl\units\i386-win32)
 
to the 'Other unit files ...' in 'Paths' tab of 'Compiler Options' of the lazarus package manager   
window.

Usage

Drop a TPSQLDatabase component on a form, for any different PostgreSQL database your application needs to connect to. Mandatory property of this component you have to set are:

Optionally you may need to set Password property for correct connection to server. Then, to activate the connection, you neet to set the Connected property to 'True'. An exception will be raised if connection failed (wrong parameters, user with no permission to access the host/database, network errors or PostgreSQL server not active). Set this property to 'False' for closing connection.

- Note about the ClientEncoding property.

text
The ClientEncoding property allows user to set a character set for the client
application different from the one defined for the database. The PostgreSQL server
make a 'translation' between the two sets.  However a "ClientEncoding change failed" 
exception may be the result of a ClientEncoding property change. This may be due to
a database character set incompatible with the clientencoding you selected. IE,  
the char set 'LATIN9' is not compatible with a  'WIN1250'. You select the default
char set for the whole database cluster when you create it with the command
'initdb', using the -E option:  IE.   'initdb -E UNICODE'.  Also, you can define a
different character set for any database you create (different from the 
default one of the whole db cluster),  also with the  -E option:

IE. 'createdb  -E UNICODE Test' 
 
                    or

CREATE DATABASE TEST WITH ENCODING 'UNICODE';

(note you must  quote the character set  name in the 'CREATE DATABASE' command).

I suggest to set UNICODE character set as the default for your db cluster (or for the
database you create), because it is compatible with the whole set of charset available
for the client, except the MULE_INTERNAL.

Now you may drop a TPSQLDataset component on the form for any table connection you need. The main property to set on this component type is the Database one. A dropdown menu allows you to select one of any TDatabase descendant component present on form (of course, you must select a TPSQLDatabase component).

You also need to provide a valid SQL statement in SQL property. Now, you are able to open the TPSQLDataset, setting to 'True' the Active property. Several exceptions are provided for signaling failing conditions. Please, refer to TDataSet documentation for infos and examples about using the TPSQLDataset component in order to access to SQL retrieved data rows as well as conneting to Data Controls components. However, procedures and functions added to parent class are explained here:

- function commandQuery ( query : String) : ShortInt.

pascal
Use this function for submit queries that doesn't returns data columns, as update queries
(ie. update, insert, delete etc.). Current dataset is not affected, however it will reflect 
changes made by execution of commandQuery itself, if it has some influence on current 
dataset.Function returns 0 if succeded, -1 if failed. No exceptions are provided.

- procedure beginTransaction

pascal
                          Starts a SQL transaction session. Changes to table may be submitted
                          using the commandQuery function.

- procedure commitTransaction

text
                          Ends a SQL transaction session, commiting changes submitted starting
                          from last beginTransaction execution.

- procedure rollbackTransaction

text
                          Ends a SQL transaction session, aborting changes.

From the Free Pascal wiki, page "TPSQL/es", as it stood on 2012-05-22 after a change by Iskraelectrica, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.