I am using a function in PostgreSQL 9.1:
CREATE FUNCTION myfunc() RETURNS trigger AS $$ ... $$ LANGUAGE plpgsql;
with a trigger:
CREATE TRIGGER mycheck
BEFORE INSERT OR UPDATE ON t
FOR EACH ROW EXECUTE PROCEDURE myfunc();
My problem now is to express a condition about events in the body of that function like (pseudocode):
IF TRIGGER_EVENT_WAS_INSERT THEN ...doThis... END IF;
How to express this condition?
(Note BEFORE INSERT OR UPDATE
in the trigger!)