Subject | more about transactions |
---|---|
Author | bemmel2003 |
Post date | 2003-03-10T08:48:36Z |
Hi,
Could someone please give a hint for best practise on transaction
management if you update or insert a record. I use TIB_query for it,
and my TIB_tranction uses autocommit, itCommitted, and does have a
timeout of 120 seconds before performing a commit.
The following code (simplified) all perform the correct task but I'm
not sure about the best code, and why it's better code:
1. doing nothing, just let the timer of IBO do the job
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null');
execsql;
end;
2. perform commit afterwards:
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null');
execsql;
end;
try IB_transaction1.commit
except IB_transaction1.rollback;showmessage('oops');end;
3. start separate transaction each time:
IB_transaction1.starttransaction;
try
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null';
execsql;
end;
finally
try IB_transaction1.commit except
IB_transaction1.rollback;showmessage('oops');end;
end;
Could someone please give a hint for best practise on transaction
management if you update or insert a record. I use TIB_query for it,
and my TIB_tranction uses autocommit, itCommitted, and does have a
timeout of 120 seconds before performing a commit.
The following code (simplified) all perform the correct task but I'm
not sure about the best code, and why it's better code:
1. doing nothing, just let the timer of IBO do the job
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null');
execsql;
end;
2. perform commit afterwards:
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null');
execsql;
end;
try IB_transaction1.commit
except IB_transaction1.rollback;showmessage('oops');end;
3. start separate transaction each time:
IB_transaction1.starttransaction;
try
with IB_query1 do
begin
sql.clear;
sql.add('update employees set date = :date where date is null';
execsql;
end;
finally
try IB_transaction1.commit except
IB_transaction1.rollback;showmessage('oops');end;
end;