Could anybody tell me where possibly can I have syntax error in trigger procedure below?
CREATE OR REPLACE FUNCTION hd.insert_insteadof_update()
RETURNS trigger AS
$BODY$
BEGIN
IF (OLD <> NEW)
THEN
NEW.set_date = now();
INSERT INTO hd.ticket_attachment
VALUES (NEW.*);
EXCEPTION WHEN UNIQUE_VIOLATION THEN END;
END IF;
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
I use PostgreSQL 8.4.
ERROR: syntax error at or near "EXCEPTION" LINE 13: EXCEPTION WHEN UNIQUE_VIOLATION THEN END;
^********** Error **********
ERROR: syntax error at or near "EXCEPTION" SQL state: 42601 Character: 356