Re: Old/New - Mailing list pgsql-general

From Tom Lane
Subject Re: Old/New
Date
Msg-id 16075.1264115760@sss.pgh.pa.us
Whole thread Raw
In response to Old/New  ("Bob Pawley" <rjpawley@shaw.ca>)
List pgsql-general
"Bob Pawley" <rjpawley@shaw.ca> writes:
> I am getting a strange result when using the following -

>  Select fluid_id into fluidid
>  from p_id.processes
>  where new.pump1 = 'True'
>  and old.pump1 = 'False'
>   or old.pump1 is null;

> The fluid_id return is fine when there is a single row. However with two rows, and updating only one of the rows, I
quiteoften get the fluid_id for the other row. 

That WHERE condition isn't constraining the SELECT at all; you're
getting the result from the first row in the table.  I think you have
some fundamental confusion about how to work with OLD and NEW in
triggers.  They're just rowtype variables, you do not need to select
from the table to examine them.

            regards, tom lane

pgsql-general by date:

Previous
From: "Bob Pawley"
Date:
Subject: Old/New
Next
From: "Gauthier, Dave"
Date:
Subject: array element replace ?