From: | san(at)cobalt(dot)rmnet(dot)it |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org |
Subject: | PL/pgSQL triggers ON INSERT OR UPDATE |
Date: | 2001-10-22 21:25:44 |
Message-ID: | 200110222125.XAA30632@cobalt.rmnet.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-novice pgsql-sql |
Hello, I'm trying to set up a trigger on insert or update
but when using the predefined variable ``OLD'' I get a
NOTICE from the trigger function about OLD not being defined yet.
Of course OLD is not defined when the function is triggered on INSERT
event, and I did not mention it if not inside a conditional block
checking for the TG_OP variable being 'UPDATE'.
For better understanding here is some code:
BEGIN
IF TG_OP = 'UPDATE' THEN
IF OLD.id <> NEW.id THEN
-- do the work
END IF
END IF;
END;
Even when TG_OP != 'UPDATE' (INSERT event) I still get an error
message from the pl/pgsql compiler (the first time the trigger is fired).
What should I do then ? Is it still possible to use the same function
for UPDATE OR INSERT events ?
TIA
--san;
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-10-22 21:37:24 | Re: CREATE TABLE AS / WITHOUT OIDs? |
Previous Message | Bruce Momjian | 2001-10-22 20:54:03 | Re: [GENERAL] To Postgres Devs : Wouldn't changing the select limit |
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-10-22 23:09:20 | Re: Getting back the primary key after INSERT |
Previous Message | Mihai Gheorghiu | 2001-10-22 21:23:49 | Re: Problems setting up PostgreSQL and Tomcat JDBC connection |
From | Date | Subject | |
---|---|---|---|
Next Message | Esteban Gutierrez Abarzua | 2001-10-22 22:35:22 | cast |
Previous Message | Joel Burton | 2001-10-22 19:54:28 | Re: oid's in views. |