Re: Trigger once again - Mailing list pgsql-general

From Oliver Elphick
Subject Re: Trigger once again
Date
Msg-id 1038523584.13298.745.camel@linda.lfix.co.uk
Whole thread Raw
In response to Trigger once again  (Adrian Klaver <aklaver@attbi.com>)
List pgsql-general
On Thu, 2002-11-28 at 21:55, Adrian Klaver wrote:
> I have created the following function:
...
>     IF new.tag_number=old.tag_number THEN
>     RAISE EXCEPTION ''Number is already present '';
...
> The trigger seems to work to well. If I update values other than the
> tag_number I get the 'Number is already present' message. I am somewhat
> confused as their is no new.tag_number value being passed to the function.
> Can anyone set me straight?

NEW contains the whole changed record; OLD contains the record before
the change.  If you "update values other than the tag_number", the
tag_number is not changed, therefore the condition is true.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The earth is the LORD'S, and the fullness thereof; the
      world, and they that dwell therein."       Psalms 24:1

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: template0 1 psql -d .. (newbie)
Next
From: Holger Klawitter
Date:
Subject: Re: Why does everyone think MySQL is easier?