Do triggers block?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Do triggers block?

fkalim
Hi,

I'm working with triggers in Derby and their order of execution is described
in the document as given below. However, I wanted to clarify whether
triggers are blocking e.g. if an AFTER trigger fires a function, does it
block until the function has finished running?

Order of execution
When a database event occurs that fires a trigger, Derby performs actions in
this order:
It fires No Cascade Before triggers.
It performs constraint checking (primary key, unique key, foreign key,
check).
It performs the insert, update, or delete.
It fires After triggers.
When multiple triggers are defined for the same database event for the same
table for the same trigger time (before or after), triggers are fired in the
order in which they were created.





--
Sent from: http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html
Reply | Threaded
Open this post in threaded view
|

Re: Do triggers block?

Rick Hillegas-3
The statement.execute() method will not return until all triggered
actions complete. If the trigger invokes a user-written java method,
then the trigger will not finish executing until the method returns. All
of the transactional work done by the statement operates within a
savepoint. That includes the transactional work done by the statement's
triggers and all of the transactional work done by user-written methods
invoked by those triggers. If a statement-level error occurs, then all
of the work done in the savepoint is rolled back--but the work done by
previous statements in the transaction is not rolled back. Waiting for
the user-written method to complete is all part of this savepoint
management.

Hope this helps,
-Rick

On 9/15/19 1:14 PM, fkalim wrote:

> Hi,
>
> I'm working with triggers in Derby and their order of execution is described
> in the document as given below. However, I wanted to clarify whether
> triggers are blocking e.g. if an AFTER trigger fires a function, does it
> block until the function has finished running?
>
> Order of execution
> When a database event occurs that fires a trigger, Derby performs actions in
> this order:
> It fires No Cascade Before triggers.
> It performs constraint checking (primary key, unique key, foreign key,
> check).
> It performs the insert, update, or delete.
> It fires After triggers.
> When multiple triggers are defined for the same database event for the same
> table for the same trigger time (before or after), triggers are fired in the
> order in which they were created.
>
>
>
>
>
> --
> Sent from: http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html
>