{"id":3157,"date":"2019-09-04T10:59:43","date_gmt":"2019-09-04T08:59:43","guid":{"rendered":"http:\/\/van-maanen.com\/?p=3157"},"modified":"2019-09-04T10:59:43","modified_gmt":"2019-09-04T08:59:43","slug":"oracle-trigger-example","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=3157","title":{"rendered":"Oracle &#8211; trigger example"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This note provides an example on a trigger. I like this example as it shows how additional business logic can be implemented.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is an example of a statement trigger: whenever a statement is issued, the trigger fires once, no matter how many records are affected.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE OR REPLACE TRIGGER security_time_check\n     BEFORE DELETE OR UPDATE ON emp\nDECLARE\n  dy_of_week   CHAR(3);\n  hh_of_day    NUMBER(2);\nBEGIN\n  dy_of_week := TO_CHAR(SYSDATE,'DY');\n  hh_of_day := TO_CHAR(SYSDATE,'HH24');\n  IF dy_of_week IN ('WO')\n     OR hh_of_day NOT BETWEEN 8 AND 17 THEN\n    RAISE_APPLICATION_ERROR(-20600, 'Transaction rejected for security reasons');\n  END IF;\nEND;\n\/<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This note provides an example on a trigger. I like this example as it shows how additional business logic can be implemented. It is an example of a statement trigger: whenever a statement is issued, the trigger fires once, no matter how many records are affected. CREATE OR REPLACE TRIGGER security_time_check BEFORE DELETE OR UPDATE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3157","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3157"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3157\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3157"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}