Database Reference
In-Depth Information
CREATE TRIGGER usagestamp
BEFORE INSERT OR UPDATE ON modify_test
FOR EACH ROW
EXECUTE PROCEDURE usagestamp();
Now, let's test out trying to update the created audit log information. First, we will
need to drop the original trigger so we don't have two trigger firing on the same table.
Then, we will try to change the values of created_by and created_at :
postgres=# DROP TRIGGER changestamp ON
modify_test;
DROP TRIGGER
postgres=# UPDATE modify_test SET created_by =
'notpostgres', created_at = '2000-01-01';
UPDATE 1
postgres=# select * from modify_test;
-[ RECORD 1 ]---+---------------------------
id | 1
data | something else
created_by | postgres
created_at | 2013-04-15 09:28:23.966179
last_changed_by | postgres
last_changed_at | 2013-04-15 09:33:25.386006
Looking at the results, you can see that the created information is still the same, but
the last changed information has been updated.
Search WWH ::




Custom Search