Re: Trigger once again - Mailing list pgsql-general

From Tariq Muhammad
Subject Re: Trigger once again
Date
Msg-id Pine.LNX.4.21.0211281736470.21997-100000@genesis.int.libertyrms.com
Whole thread Raw
In response to Trigger once again  (Adrian Klaver <aklaver@attbi.com>)
List pgsql-general
On Thu, 28 Nov 2002, Adrian Klaver wrote:

> 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?

Try it by validating 2 columns, that should do the trick:

 CREATE OR REPLACE FUNCTION validate_tag_number()
       RETURNS OPAQUE AS '
     BEGIN
       IF new.tag_number=old.tag_number and new.other_column=old.other_column THEN
        RAISE EXCEPTION ''Tag is already present '';
       END IF;
        RETURN NEW;
     END;
       'LANGUAGE 'plpgsql';

If that doesn't work then send me the schema of your table and I will work
on it.

Tariq Muhammad
Liberty RMS
tariq@libertyrms.info
v:416-646-3304 x 111
c:416-993-1859
p:416-381-1457



pgsql-general by date:

Previous
From: Holger Klawitter
Date:
Subject: Re: Why does everyone think MySQL is easier?
Next
From: Tom Lane
Date:
Subject: Re: Trigger once again