Last active
May 5, 2022 05:09
-
-
Save froop/f13a443a129527132e33649347e02158 to your computer and use it in GitHub Desktop.
[PostgreSQL] trigger sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- psql -p 24001 -U hinemos -f create-trigger-sample.sql | |
CREATE OR REPLACE FUNCTION log_cc_cfg_facility_relation_delete() RETURNS TRIGGER AS $$ | |
BEGIN | |
RAISE LOG 'DELETE cc_cfg_facility_relation: % %', | |
OLD.parent_facility_id, OLD.child_facility_id; | |
RETURN NULL; | |
END | |
$$ LANGUAGE plpgsql; | |
CREATE TRIGGER trg_cc_cfg_facility_relation_delete | |
AFTER DELETE ON setting.cc_cfg_facility_relation | |
FOR EACH ROW | |
EXECUTE PROCEDURE log_cc_cfg_facility_relation_delete(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- psql -p 24001 -U hinemos -f drop-trigger-sample.sql | |
DROP TRIGGER IF EXISTS trg_cc_cfg_facility_relation_delete | |
ON setting.cc_cfg_facility_relation; | |
DROP FUNCTION IF EXISTS log_cc_cfg_facility_relation_delete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment