Re: Sequence of SQL command execution involving triggers and stored procedures.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Omkar Rath" <orath(at)cisco(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sequence of SQL command execution involving triggers and stored procedures.
Date: 2004-09-18 16:39:21
Message-ID: 4960.1095525561@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Omkar Rath" <orath(at)cisco(dot)com> writes:
> Say there is a stored procedure i.e FUNCTION sp_foo(...) which has say,
> SQL commands (any of SELECT,INSERT,UPDATE,DELETE) in its body, say S1
> followed by S2 then S3.... Furthermore, execution of statement S2
> results in trigger functions getting invoked (that contain yet other SQL
> statements).
>
> By the time, the trigger functions execute (as a result of S2), S3 has
> already executed.

In existing PG releases, AFTER triggers are always fired at the
completion of the whole interactive command (ie, the outer SELECT that
called sp_foo).

There are changes in 8.0 to fire them at the end of the specific query
that triggered them, which I believe will do what you want.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Browne 2004-09-18 17:20:15 Re: How to check postgres running or not ?
Previous Message Greg Stark 2004-09-18 15:39:01 Re: 1-byte integers