Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Transactions
Thu, Nov 13 2008 10:23 AMPermanent Link

Leslie
Tim,

1. Is there a way to query from within  a stored procedure/trigger/script if it is
executed int the context of a transaction?

2. Are simple update/insert/delete commands executed in the context of a transaction if
none is tarted by the application? I would like to understand what to expect when the
updated table has triggers updating other tables, which has triggers updating other tables
.... Are the triggers, and triggers of the other updated tables executed in a atomic fashion?

Regards,
Leslie
Thu, Nov 13 2008 11:44 AMPermanent Link

Leslie
<<1. Is there a way to query from within  a stored procedure/trigger/script if it is
executed int the context of a transaction?>>


I have on solution. Is this Efficient?

BEGIN
Declare WasInTransaction bool;
 Begin
   START TRANSACTION
 Exception
     Set WasInTransaction = True;
 end;
...
 if not WasInTransaction then
   Commit;
 end if;
...
EXCEPTION
 if not WasInTransaction then
   RollBack;;
 end if;
END;

Regards,
Leslie
Thu, Nov 13 2008 11:45 AMPermanent Link

Leslie
I have on solution = I have one solution
Thu, Nov 13 2008 3:27 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Leslie,

<< 1. Is there a way to query from within  a stored procedure/trigger/script
if it is executed int the context of a transaction? >>

Not at this time, no.  It is assumed that triggers and stored procedures
shouldn't care either way.

<< 2. Are simple update/insert/delete commands executed in the context of a
transaction if none is tarted by the application? >>

Sort of.  They are batched up, but occasionally are flushed to disk for
performance purposes.

<< I would like to understand what to expect when the updated table has
triggers updating other tables, which has triggers updating other tables ...
Are the triggers, and triggers of the other updated tables executed in a
atomic fashion?  >>

Triggers are only executed in an atomic fashion if they are executed under
an active transaction.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Nov 13 2008 3:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Leslie,

<< I have on solution. Is this Efficient? >>

Efficient enough for your purposes.  You'll want to change this line,
however:

Declare WasInTransaction bool;

to this:

Declare WasInTransaction bool DEFAULT False;

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Nov 13 2008 3:57 PMPermanent Link

Leslie
Thank you Tim!

Regards,
Leslie
Image