Quantcast

Invoke trigger after commit

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Invoke trigger after commit

js-28
Hi,

is there a way to invoke a trigger only if the current transaction is
committed?
The problem is that my trigger does some kind of logging outside the
database and therefore must not be invoked if the transaction is rolled
back.

Thanks in advance
Jan

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [hidden email] so that your
       message can get through to the mailing list cleanly
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Invoke trigger after commit

Alexander Staubo-3
On 5/10/07, Jan Strube <[hidden email]> wrote:
> is there a way to invoke a trigger only if the current transaction is
> committed?
> The problem is that my trigger does some kind of logging outside the
> database and therefore must not be invoked if the transaction is rolled
> back.

PostgreSQL does not implement a kind of "on commit" trigger, but you
can simulate them using "notify" and "listen", which are
transactional:

  http://www.postgresql.org/docs/8.2/interactive/sql-notify.html

Alexander.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Invoke trigger after commit

Sim Zacks
In reply to this post by js-28
Use a Listen/Notify daemon application and put the Notify on the last line of the transaction.
If it does the notify that means that the transaction was completed successfully.

Sim

Jan Strube wrote:

> Hi,
>
> is there a way to invoke a trigger only if the current transaction is
> committed?
> The problem is that my trigger does some kind of logging outside the
> database and therefore must not be invoked if the transaction is rolled
> back.
>
> Thanks in advance
> Jan
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to [hidden email] so that your
>       message can get through to the mailing list cleanly
>

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
Loading...