Re: Old/New

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
Cc: "Postgresql" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Old/New
Date: 2010-01-21 23:16:00
Message-ID: 16075.1264115760@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Bob Pawley" <rjpawley(at)shaw(dot)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 quite often 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

In response to

  • Old/New at 2010-01-21 23:08:39 from Bob Pawley

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2010-01-21 23:45:50 array element replace ?
Previous Message Bob Pawley 2010-01-21 23:08:39 Old/New