Re: [GENERAL] TG_OP and undefined OLD values

2005-08-26 Thread Tom Lane
Mike Nolan <[EMAIL PROTECTED]> writes: > The following code fails because the OLD value is not defined: >if TG_OP = ''INSERT'' >or (TG_OP = ''UPDATE'' and NEW.column1 != coalesce(OLD.column1,''--'')) > then > column2 := ''CHANGED''; >end if; > Shouldn't OLD.column1 not even be

[GENERAL] TG_OP and undefined OLD values

2005-08-26 Thread Mike Nolan
I'm trying to write some code in a trigger that fires on both an insert and an update. At one point I need to update a column either on an insert or if the value of the column has changed. The following code fails because the OLD value is not defined: if TG_OP = ''INSERT'' or (TG_OP = ''