Getting out of transaction if exception occurred
Posted: 25.08.2011, 06:51
Hi there
Using Zeos 6.6.6-stable with Delphi6 on Postgres 8.3
I'm having difficulty implementing transactions in my application in the way that I feel will be most practical.
My app is running lengthy DB processes which I'd like to put in transactions; I've implemented it like this:
ExecSQL( 'begin;' ); //(function executing scripts using TZSQLProcessor)
try
//...lengthy process start
ExecSQL(.... )
//...lengthy process ends
ExecSQL('commit');
except
ExecSQL('rollback');
raise; // exception should occur
end;
My requirement is this when an exception occurs:
1 ) the exception (normally EZSQLException) should be raised
2 ) all DB changes made in this transaction should be rolled back
3) the DB session should be able to continue processing transactions
My problem is that no matter how I try to tweak the code above, when a EZSQLException occurs,
the system excepts with the standard:
"SQL Error: ERROR: current transaction is aborted, commands ignored until end of transaction block."
and the connection to the DB should be restarted.
Is there any way in which I can get past this?
Thanks for any help
Using Zeos 6.6.6-stable with Delphi6 on Postgres 8.3
I'm having difficulty implementing transactions in my application in the way that I feel will be most practical.
My app is running lengthy DB processes which I'd like to put in transactions; I've implemented it like this:
ExecSQL( 'begin;' ); //(function executing scripts using TZSQLProcessor)
try
//...lengthy process start
ExecSQL(.... )
//...lengthy process ends
ExecSQL('commit');
except
ExecSQL('rollback');
raise; // exception should occur
end;
My requirement is this when an exception occurs:
1 ) the exception (normally EZSQLException) should be raised
2 ) all DB changes made in this transaction should be rolled back
3) the DB session should be able to continue processing transactions
My problem is that no matter how I try to tweak the code above, when a EZSQLException occurs,
the system excepts with the standard:
"SQL Error: ERROR: current transaction is aborted, commands ignored until end of transaction block."
and the connection to the DB should be restarted.
Is there any way in which I can get past this?
Thanks for any help