Re: Order of Update - Second Try

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Order of Update - Second Try
Date: 2006-03-21 18:56:40
Message-ID: 200603211356.40351.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan,

Thanks for the reply. We will be upgrading to version 8.x in the third quarter
of the year. As I said, I have a workaround. I just wanted to know why it was
behaving that way and you provided that. Thanks for the help.

On Tuesday 21 March 2006 11:36 am, Stephan Szabo saith:
> > 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).
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Quote: 71
"When the Lord calls me home, whenever that may be, I will leave with
the greatest love for this country of ours and eternal optimism for
its future. I now begin the journey that will lead me into the sunset
of my life. I know that for America there will always be a bright dawn
ahead."

--Ronald Reagan

Work: 1-336-372-6812
Cell: 1-336-363-4719
email: terry(at)esc1(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Maxwell 2006-03-21 19:00:14 [GENERAL] A real currency type
Previous Message Thomas F. O'Connell 2006-03-21 18:14:28 Re: Troubling On-line Backup LOG messages