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:
IF TG_OP = 'UPDATE' THEN
IF OLD.id <> NEW.id THEN
-- do the work
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 ?
pgsql-novice by date
|Next:||From: Josh Berkus||Date: 2001-10-22 23:09:20|
|Subject: Re: Getting back the primary key after INSERT|
|Previous:||From: Mihai Gheorghiu||Date: 2001-10-22 21:23:49|
|Subject: Re: Problems setting up PostgreSQL and Tomcat JDBC connection|
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2001-10-22 21:37:24|
|Subject: Re: CREATE TABLE AS / WITHOUT OIDs? |
|Previous:||From: Bruce Momjian||Date: 2001-10-22 20:54:03|
|Subject: Re: [GENERAL] To Postgres Devs : Wouldn't changing the select limit|
pgsql-sql by date
|Next:||From: Esteban Gutierrez Abarzua||Date: 2001-10-22 22:35:22|
|Previous:||From: Joel Burton||Date: 2001-10-22 19:54:28|
|Subject: Re: oid's in views.|