Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

postgres create trigger if not exists

-- SYNTAX
CRRATE TRIGGER trigger_name {BEFORE|AFTER|INSTEAD OF} { event [ OR ... ] }
ON table_name
[ FROM referenced_table_name ]
[ NOT DEFERRABLE | [ DEFERRABLE ] [ INITIALLY IMMEDIATE | INITIALLY DEFERRED ] ]
[ REFERENCING { { OLD | NEW } TABLE [ AS ] transition_relation_name } [ ... ] ]
[ FOR [ EACH ] { ROW | STATEMENT } ]
[ WHEN ( condition ) ]
EXECUTE {FUNCTION|PROCEDURE} function_name ( arguments )

-- EXAMPLE
CREATE TRIGGER test_trigger
  AFTER INSERT
  ON test_table
  FOR EACH ROW
  EXECUTE PROCEDURE test();
Source by www.enterprisedb.com #
 
PREVIOUS NEXT
Tagged: #postgres #create #trigger #exists
ADD COMMENT
Topic
Name
5+8 =