Database Reference
In-Depth Information
DELETE and INSERT triggers correspondingly. Rather, they are unassigned.
Using an unassigned variable in any other way except assigning to it in PL/
pgSQL results in an error.
We are now ready to define our new logging trigger:
CREATE TRIGGER audit_log
AFTER INSERT OR UPDATE OR DELETE
ON notify_test
FOR EACH ROW
EXECUTE PROCEDURE audit_trigger();
Running a small test, we remove our original notify triggers from the notify_test
table and perform a few simple operations:
postgres=# DROP TRIGGER notify_trigger ON
notify_test;
DROP TRIGGER
postgres=# DROP TRIGGER notify_truncate_trigger
ON notify_test;
DROP TRIGGER
postgres=# TRUNCATE notify_test;
TRUNCATE TABLE
postgres=# INSERT INTO notify_test VALUES (1);
INSERT 0 1
postgres=# UPDATE notify_test SET i = 2;
UPDATE 1
postgres=# DELETE FROM notify_test;
DELETE 1
postgres=# SELECT * FROM audit_log;
-[ RECORD 1 ]--+---------------------------
username | postgres
event_time_utc | 2013-04-14 13:14:18.501529
table_name | public.notify_test
operation | INSERT
Search WWH ::




Custom Search