Page 1 of 1

Problems with autocommit mode

Posted: 01.04.2013, 15:27
by jpgonzalez
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...

Posted: 02.04.2013, 08:08
by marsupilami
Hello jpgonzalez,

could you please check wether this also happens in the current stable version 7.0.3?
Best regards,

Jan

Posted: 03.04.2013, 14:43
by jpgonzalez
marsupilami wrote:Hello jpgonzalez,

could you please check wether this also happens in the current stable version 7.0.3?
Best regards,

Jan
I installed the version 7.0.3-stable, and I still get the same error.
I do not understand that part of the code inserted in a block StartTransaction / Commit.
Be a problem of try / except???

Thanks!!!!

Posted: 04.04.2013, 06:02
by jpgonzalez
I found the solucoin in www.clubdelphi.com/foros
Had to put TRansactIsolationLevel = readCommited

Thanks anyway!!!