Stored procedure will wait until trigger execution is done?
455605Oct 16 2006 — edited Oct 19 2006Hi,
We need to implement an Audit trail in our project. This audit trail tracks the changes of each field of a table. We also need the USERID to be saved into the audit table.
We will have a stored procedure to do updates and inserts. And we are thinking of using a trigger to take care of the audit trail. The stored procedure will set the USERID in a context variable. The trigger of the changed table then will grab the USERID from the context variable and save the table field changes together with the USERID into the audit table. After all is done, the USERID will be deleted from the context at the very end of the stored procedure. Now we search the internet to check if this holds true that stored procedure will wait until the trigger execution is done. We know the triggers are like stored procedures. We also try to test this problem by putting debug statements in the trigger with a minute delay and the logs show that the stored proc really waited for the trigger to finish first before finishing up the stored procedure. We just need a concreate documentation somewhere that confirms and explains clearly that triggers are like stored procedures and the stored procedure will wait for triggers to finish first before executing the rest of its statements.
Thanks,
Baldwin