db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Bradbury <Stan.Bradb...@gmail.com>
Subject Re: Triggers and Transaction behaviour
Date Fri, 11 Aug 2006 15:33:29 GMT
Alexander Schatten wrote:
> I could not find proper information in the manuals about triggers and 
> transactions.
> If e.g., within a transaction, say, a insert statement is performed, 
> and this statement fires off a trigger, and then later on, the 
> transaction is rolled back: what about the activities of the trigger?
> Is there some more detailed document about this behaviour?
> thank you!
> Alex
Hi Alex -
The answer depends on the type of trigger.  A transaction occurs within 
a single connection.  For simple, single SQL statement triggers the 
trigger activities are part of the transaction (execute within the 
context of the current connection) and are rolled back.  Should a SQL 
statement trigger fail it raises an exception that is passed to the 
calling routine.  This is covered here:

When the trigger calls a JDBC function then the answer depends on how 
the JDBC is coded.  The background for considering this type of trigger 
is laid here:
NOTE:  I find it best to have trigger code always share the transaction 
space (#1).

You can code the JDBC two ways.
 >> 1. Coding to share the transaction space:

 >> 2. Coding that operates outside of the transaction space:

View raw message