Re: Order of Update - Second Try

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Terry Lee Tucker <terry(at)esc1(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Order of Update - Second Try
Date: 2006-03-21 16:36:27
Message-ID: 20060321083359.G72634@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Ok, find attached a script called test.sql that will create three tables
> called parent, child, and totals. It will create a simple AFTER UPDATE
> trigger on child and a BEFORE trigger on parent simply to show that the
> values of batch and chkno are set to NULL right in the beginning. Just load
> the thing in with the \i command. There is a function created called
> myfunc(int). Simply do: SELECT myfunc(99); to see what happens. After you
> execute the function, you will find that parent.total is zero,
> child.apply_amt for each record is zero, but totals is still set to 1500. It
> should be 1000.
>
> Version info:
> rnd=# select version();
> version
> --------------------------------------------------------------------------------------------------------------
> PostgreSQL 7.4.6 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.2.3
> 20030502 (Red Hat Linux 3.2.3-49)
> (1 row)
>
> Any insight is appreciated.

I think in 8.0 or later it'd do what you want, however IIRC in 7.4 the
after triggers are delayed until after the full execution of the function
myfunc (ie, at the end of the outer statement).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas F. O'Connell 2006-03-21 16:47:35 Troubling On-line Backup LOG messages
Previous Message Shulman, Michael 2006-03-21 16:27:29 Connection error