Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: how to do a transactions (d2006/oracle)
how to do a transactions (d2006/oracle)
Posted: 2007/08/27 04:00
 
hello,

i'm workung with anydac for some days and now i don't know how to do a transaction with more than one sql-command. i hope you can help me and give me an example.

greets,
shark
Re:how to do a transactions (d2006/oracle)
Posted: 2007/08/27 07:27
 
i believe that you just have to wrap your transaction with "BEGIN;" and "COMMIT;" sql statement.

for example (delphi with mysql)...


 ADQuery1.SQL.Text := 'BEGIN;'; ADQuery1.ExecSQL; ADQuery1.SQL.Text := 'SELECT balance FROM checking WHERE customer_id = 10233276'; ADQuery1.ExecSQL; ADQuery1.SQL.Text := 'UPDATE checking SET balance = balance - 200.00 WHERE customer_id = 10233276;'; ADQuery1.ExecSQL; ADQuery1.SQL.Text := 'UPDATE savings  SET balance = balance + 200.00 WHERE customer_id = 10233276;'; ADQuery1.ExecSQL; ADQuery1.SQL.Text := 'COMMIT;'; ADQuery1.ExecSQL;



this works for me..

regards,
- mark
Re:how to do a transactions (d2006/oracle)
Posted: 2007/08/27 08:08
 
Hello

1) Executing BEGIN / COMMIT in 1.x may lead to problems. Because after BEGIN TADConnection.IsTxActive will return False. But 2.0 will work OK with that.
2) You always can use TADConnection.StartTransaction / Commit / Rollback methods. Although AnyDAC 1.x has no help, you can see help for BDE TDatabase.

Regards,
Dmitry
Re:how to do a transactions (d2006/oracle)
Posted: 2007/08/28 06:10
 
Hello,

because of your help it just works fine

shark