I have a trigger that sets an expires column to
last_access+expiry::interval if expires IS NULL or if the expires value
isn't being set or changed.
IF NEW.expires IS NULL OR NEW.expires = OLD.expires THEN
NEW.expires = NEW.last_access+NEW.expiry:interval;
END IF;
The problem here is OLD doesn't exist on the first INSERT which throws
an error. It seems PL/pgSQL doesn't have C's short-circuit booleans.
a) Is there a way around this?
b) is there a 'right' way to determine if a column is being changed?
Paul (total PL/pgSQL newbie)
--
Paul Makepeace ................................ http://paulm.com/ecademy
"If I had new shoes, then he wouldn't sing Halleighluha."
-- http://paulm.com/toys/surrealism/