You probably want to run the trigger "BEFORE UPDATE" unless you have some other code depending on the value of modified_date during the update, and also instead of "RETURN NULL;" do a "RETURN NEW;". Here's an example from one of my triggers:
Trigger definition:
CREATE TRIGGER trig_rec_returndate
BEFORE UPDATE
ON rec_main
FOR EACH ROW
EXECUTE PROCEDURE fun_rec_returndate();
Trigger function definition:
CREATE OR REPLACE FUNCTION fun_rec_returndate()
RETURNS "trigger" AS
'BEGIN
IF NEW.returncode IS NOT NULL THEN
IF OLD.returndate IS NULL THEN
NEW.returndate := \'now\';
END IF;
END IF;
RETURN NEW;
END;'
LANGUAGE 'plpgsql' VOLATILE;
In that case returndate is a timestamp. Hope it helps!
Jason Minion
I have difficulty in setting a trigger to have trail of my project
I need to update the modified_date of my database tables through trigger as
CREATE OR REPLACE TRIGGER taril_trigger AFTER UPDATE ON test_trigger FOR EACH ROW
EXECUTE PROCEDURE pro_trail();
pro_trail(){
BEGIN
NEW.modified_date=(select current_timestamp)
return NULL;
END;
}
Can anybody help me out!!!
Mandar M. Bhosale