I get a SInvalidOpInNonAutoCommit exception when i call the StartTransaction method.
I found the following method in ZConnection.pas:
procedure TZConnection.CheckAutoCommitMode;
begin
if not FAutoCommit and (FExplicitTransactionCounter = 0) then
raise EZDatabaseError.Create(SInvalidOpInNonAutoCommit);
end;
When I write the condition to
"not FAutoCommit and (FExplicitTransactionCounter <> 0)"
then everything seems correct
ZeosDBO 6.6.2 postgresql StartTransaction
Moderators: gto, cipto_kh, EgonHugeist
ZeosDBO 6.6.2 postgresql StartTransaction
You do not have the required permissions to view the files attached to this post.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Bakter,
Please have a look at the other forum topics concerning StartTransaction.
In short : StartTransaction should only be used when in AutoCommit Mode. It's an 'escape from autocommit' feature. Otherwise transaction handling happens automatically. Just use rollback and commit where you need it.
Mark
Please have a look at the other forum topics concerning StartTransaction.
In short : StartTransaction should only be used when in AutoCommit Mode. It's an 'escape from autocommit' feature. Otherwise transaction handling happens automatically. Just use rollback and commit where you need it.
Mark
thanks for the information
it's quite strange behavour first hear:D
I used to set AutoCommit to False then call StartTranscation and open a try..except block, then set AutoCommit to True.
So I think, I would remove then 'AutoCommit changing lines', and everythink will be fine, it's right?
When should I use the AutoCommit = False mode?
it's quite strange behavour first hear:D
I used to set AutoCommit to False then call StartTranscation and open a try..except block, then set AutoCommit to True.
So I think, I would remove then 'AutoCommit changing lines', and everythink will be fine, it's right?
When should I use the AutoCommit = False mode?
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
When you want transactions and don't want to use starttransaction, of course...
Set it to false and your life should be easy. Transaction opened and closed for you. Just do your dml and call commit afterwards. It's similar to the way it works in Oracle or Mysql. There you don't start the transactions explicitly either.
Mark
Set it to false and your life should be easy. Transaction opened and closed for you. Just do your dml and call commit afterwards. It's similar to the way it works in Oracle or Mysql. There you don't start the transactions explicitly either.
Mark
-
- Fresh Boarder
- Posts: 5
- Joined: 31.03.2013, 21:07
I use ZConnection with de autocommit = true
I Have this code:
try
DmMain.ZConnection.StartTransaction;
................
DmOperacionesVehiculos.QryInsertarVehiculo.ExecSQL;
................
................
DmOperacionesVehiculos.QryGuardarOperacion.ExecSQL;
................
DmOperacionesVehiculos.QryGuardarBoleto.ExecSQL;
................
................
DmMain.ZConnection.Commit;
ShowMessage('La operacion de compra se ha guardado con exito');
except
DmMain.ZConnection.Rollback;
ShowMessage('No se pudo guardar la compra');
end;
When I have a problem in the second query (QryGuardarOperacion), Rollback don´t work correctly, because the first query (QryInsertarVehiculo) post the data in the BD, despite i use startTransaction.
This problem creates inconsistency in the database, because the vehicle is post, but not the other information.
I don´t know if this is a bug of the Zeos version.
When I use the autocommit = false, the data is not post in the BD despite I use the commit command.
After that, I tested putting autocommit = false, without the command StartTransaction
This was running the entire block of code perfectly, but the data is not stored in the database.
I could see the data in the program, but not in the database, as if making a post in memory.
I do not know what happens, but in both cases (autocommit = autocommit = true and false) bring me any problems.
Can you tell me what can I do?
The Zeos Version is = 7.0.0-dev
PD: sorry for my english...
I Have this code:
try
DmMain.ZConnection.StartTransaction;
................
DmOperacionesVehiculos.QryInsertarVehiculo.ExecSQL;
................
................
DmOperacionesVehiculos.QryGuardarOperacion.ExecSQL;
................
DmOperacionesVehiculos.QryGuardarBoleto.ExecSQL;
................
................
DmMain.ZConnection.Commit;
ShowMessage('La operacion de compra se ha guardado con exito');
except
DmMain.ZConnection.Rollback;
ShowMessage('No se pudo guardar la compra');
end;
When I have a problem in the second query (QryGuardarOperacion), Rollback don´t work correctly, because the first query (QryInsertarVehiculo) post the data in the BD, despite i use startTransaction.
This problem creates inconsistency in the database, because the vehicle is post, but not the other information.
I don´t know if this is a bug of the Zeos version.
When I use the autocommit = false, the data is not post in the BD despite I use the commit command.
After that, I tested putting autocommit = false, without the command StartTransaction
This was running the entire block of code perfectly, but the data is not stored in the database.
I could see the data in the program, but not in the database, as if making a post in memory.
I do not know what happens, but in both cases (autocommit = autocommit = true and false) bring me any problems.
Can you tell me what can I do?
The Zeos Version is = 7.0.0-dev
PD: sorry for my english...