Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   En FIBPlus uso de autocommit (https://www.clubdelphi.com/foros/showthread.php?t=75530)

El_Raso 31-08-2011 01:10:40

En FIBPlus uso de autocommit
 
Un Saludo a la comunidad....

Tengo una duda... uso las FIBPlus la 6.9.5 con Delphi 7 (este componente es excelente), si uso AutoCommit como True en la Propiedad de una Tabla debo de iniciar la transaccion tambien, osea, la propiedad StarTransaction = True

O digame alguien cual es la forma correcta.

Gracias.

Caral 31-08-2011 02:21:10

Hola
No conozco los componentes FibPlus pero el Commit cierra la tabla.
Verifica que exista en ese componente el CommitRetaining que lo que hace es hacer un commit pero sin cerrar la tabla.
Saludos

Casimiro Notevi 31-08-2011 10:08:20

En la web de fibplus puedes descargar unos tutoriales (FIBplus devguide1.pdf y FIBplus devguide2.pdf), en uno de ellos dice:

Cita:

Working with transactions
A transaction is an operation of database transfer from one consistent state to another.
All operations with the dataset (data/metadata changes) are done in the context of a
transaction. To understand special FIBPlus features completely you need to know about
InterBase / FIBPlus transactions. Please read the topic «Working with Transaction» in
ApiGuide.pdf for InterBase.
All the changes done in the transaction can be either committed (in case there are no errors) by
Commit or rolled back (Rollback). Besides these basic methods TpFIBTransaction has their
context saving analogues: CommitRetaining and RollbackRetaining, i.e. on the client side, these
will not close a TpFibQuery or TpFibDataset.
To start the transaction you should call the StartTransaction method or set the Active property
to True. To commit the transaction call Commit/CommitRetaing, to roll it back -
Rollback/RollbackRetaining.
TpFIBQuery and TpFIBDataSet components have some properties which help to control
transactions automatically. In particular they are: the TpFIBDataSet.AutoCommit property; the
poStartTransaction parameter in TpFIBDataSet.Options; qoStartTransaction and
qoCommitTransaction in TpFIBQuery.Options.
How to set transaction parameters
Transaction parameters are not a trivial topic and require much explanation, so FIBPlus
DevGuide won’t cover the subject in detail. We highly recommend you to read InterBase
ApiGuide.pdf to understand how transactions work.
Nevertheless in most cases you do not need to know about all peculiarities of transaction control
at the API level. FIBPlus has a number of mechanisms which help developers’ work easier. I.e.
TpFIBTransaction has three basic transaction types: tpbDefault, tpbReadCommited,
tpbRepeatableRead. At design time you can also create special types of your own in the
TpFIBTransaction editor and use them as internal ones. Set the transaction type to set its
parameters::
TpbDefault – parameters must be set in TRParams
tbpReadCommited – shows the ReadCommited isolation level
tbpRepeatableRead – shows the RepeatableRead isolation level
Planning to use transactions in the application
Efficient InterBase/Firebird applications depend heavily on correct transaction use. In a multi-
generation architecture (record versioning) Update transactions retain record versions.
So in general try to make the Update transactions as short as possible. Read-only transactions
can remain open because they do not retain versions.

Chris 01-09-2011 00:10:51

Cita:

Empezado por El_Raso (Mensaje 410482)
Un Saludo a la comunidad....

Tengo una duda... uso las FIBPlus la 6.9.5 con Delphi 7 (este componente es excelente), si uso AutoCommit como True en la Propiedad de una Tabla debo de iniciar la transaccion tambien, osea, la propiedad StarTransaction = True

O digame alguien cual es la forma correcta.

Gracias.

Todo depende! AutoCommit se utiliza para hacer "commit" automáticamente luego de que guardas el cambio a un registro o lo eliminas. Normalmente, para que te funcione de maravillas debes utilizar la propiedad UpdateTransaction y asignarla a un componente de transacción que no sea el mismo utilizado en la propiedad Transaction.

StartTransaction se utiliza para iniciar automáticamente la transacción cuando abres la tabla, si es que la transacción aún no se ha iniciado.

En resumen, activa ambas propiedades y utiliza dos transacciones independientes. Una transacción para lectura y otra para escritura.


Saludos,
Chris


La franja horaria es GMT +2. Ahora son las 08:07:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi