Postgresql: Trigger is not working at times
0
votes
1
answer
656
views
I have a PostgreSQL trigger that is not firing sometimes, even though the status is always shown as "enabled".
My trigger code is as follows:
CREATE OR REPLACE FUNCTION audit_src_exhibit() RETURNS trigger AS $BODY$
BEGIN
IF TG_OP = 'INSERT' then
if new.audit_created_date is null THEN
new.audit_created_date := current_timestamp;
new.audit_created_by := session_user::text;
end if;
else
if new.audit_modified_date is null THEN
new.audit_modified_date := current_timestamp;
new.audit_modified_by := session_user::text;
end if;
END IF;
RETURN NEW;
END; $BODY$ LANGUAGE plpgsql VOLATILE;
CREATE TRIGGER audit_src_exhibit_tr
BEFORE INSERT OR UPDATE ON
FOR EACH ROW EXECUTE PROCEDURE audit_src_exhibit();
Is there any specific reason for this behaviour?
Does my code show any signs of known issues which would result in triggers not firing?
I am getting the audit columns as empty even though some insert and update happened today
Asked by Arun
(13 rep)
Feb 7, 2023, 08:07 AM
Last activity: Jun 15, 2024, 02:01 PM
Last activity: Jun 15, 2024, 02:01 PM