Subject Re: [IBO] more about transactions
Author Jason Wharton
If you are only executing a single statement like this don't use a query
component. Simply use the ExecuteImmediate() method and also don't use
parameters if you are not holding a prepared statement to be used
repeatedly. If you commit right after this, that's great. If you don't then
you may at least want to call the Transaction.Activate method so that it
will know some kind of statement was executed. This flags the transaction to
know that something has been sent to the server.

HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com

-- We may not have it all together --
-- But together we have it all --


----- Original Message -----
From: "bemmel2003" <info@...>
To: <IBObjects@yahoogroups.com>
Sent: Monday, March 10, 2003 1:48 AM
Subject: [IBO] more about transactions


> 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;
>
>