Monday, September 22, 2008

Trigger to mimic MySQL "last modified" datatype in Oracle

ALTER TABLE YOUR_TABLE ADD (LAST_MODIFIED DATE);

CREATE OR REPLACE
TRIGGER YOUR_TABLE_BEFORE_INS_UPD BEFORE INSERT OR UPDATE
ON YOUR_TABLE
FOR EACH ROW
DECLARE CURRENT_TIME DATE;
BEGIN
CURRENT_TIME := SYSDATE;
:new.last_modified := CURRENT_TIME;
END;



No comments: