Re: Before/After trigger sequencing questiont

From: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Before/After trigger sequencing questiont
Date: 2004-07-28 11:06:18
Message-ID: opsbug4srgcq72hf@musicbox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I think you're right : the transaction which updated the rows is not
commited yet when you call your external php procedure, and thus it does
not see the updated rows.

This is tricky because you can't commit in a plsql function.

You could add the emails to be sent to a table, which would be looked up
by a cron task sending emails and deleting the records afterwards.

You could have your perl function (which runs inside your transaction)
pass the data tot the PHP script.

You could also send your email from Perl.

> 1. A record was inserted into a table with about a million rows in it.
> 2. This insert triggered a before insert procedure that updated several
> values in a second table, one with about 580,000 rows in it.
> (This was via several different update statements in the trigger
> function.)
> 3. The 'after insert' trigger on the first table calls another procedure
> using plperlu which in turn executes an external PHP program that
> does a lookup on the 2nd table (using one of the updated values as
> a key) then sends some e-mail. It didn't find the record with the
> updated value.
>
> In thinking it through while typing typing this note, I think the problem
> is that the external PHP program doesn't see record with the updated
> value
> yet because the transaction hasn't been completed.
> --
> Mike Nolan
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pierre-Frédéric Caillaud 2004-07-28 11:09:17 Re: altering a table to set serial function
Previous Message Chris 2004-07-28 10:58:57 Re: Everlasting SQL query