Pl sql trigger if updating

There are optional declaration and exception sections, like any other PL/SQL block, if required.

pl sql trigger if updating-14pl sql trigger if updating-29pl sql trigger if updating-16

*** FORALL - INSERT *** BEFORE STATEMENT - INSERT BEFORE EACH ROW - INSERT (new.id=1) AFTER EACH ROW - INSERT (new.id=1) BEFORE EACH ROW - INSERT (new.id=2) AFTER EACH ROW - INSERT (new.id=2) BEFORE EACH ROW - INSERT (new.id=3) AFTER EACH ROW - INSERT (new.id=3) BEFORE EACH ROW - INSERT (new.id=4) AFTER EACH ROW - INSERT (new.id=4) BEFORE EACH ROW - INSERT (new.id=5) AFTER EACH ROW - INSERT (new.id=5) AFTER STATEMENT - INSERT *** FORALL - UPDATE *** BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=1 old.id=1) AFTER EACH ROW - UPDATE (new.id=1 old.id=1) AFTER STATEMENT - UPDATE BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=2 old.id=2) AFTER EACH ROW - UPDATE (new.id=2 old.id=2) AFTER STATEMENT - UPDATE BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=3 old.id=3) AFTER EACH ROW - UPDATE (new.id=3 old.id=3) AFTER STATEMENT - UPDATE BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=4 old.id=4) AFTER EACH ROW - UPDATE (new.id=4 old.id=4) AFTER STATEMENT - UPDATE BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=5 old.id=5) AFTER EACH ROW - UPDATE (new.id=5 old.id=5) AFTER STATEMENT - UPDATE *** FORALL - DELETE *** BEFORE STATEMENT - DELETE BEFORE EACH ROW - DELETE (old.id=1) AFTER EACH ROW - DELETE (old.id=1) AFTER STATEMENT - DELETE BEFORE STATEMENT - DELETE BEFORE EACH ROW - DELETE (old.id=2) AFTER EACH ROW - DELETE (old.id=2) AFTER STATEMENT - DELETE BEFORE STATEMENT - DELETE BEFORE EACH ROW - DELETE (old.id=3) AFTER EACH ROW - DELETE (old.id=3) AFTER STATEMENT - DELETE BEFORE STATEMENT - DELETE BEFORE EACH ROW - DELETE (old.id=4) AFTER EACH ROW - DELETE (old.id=4) AFTER STATEMENT - DELETE BEFORE STATEMENT - DELETE BEFORE EACH ROW - DELETE (old.id=5) AFTER EACH ROW - DELETE (old.id=5) AFTER STATEMENT - DELETE PL/SQL procedure successfully completed.trigger_test_api.g_LOOP DBMS_OUTPUT.put_line(trigger_test_api.g_tab(i)); END LOOP; trigger_test_api.g_tab.delete; END trigger_test_as_trg; / COLUMN object_name FORMAT A20 SELECT object_name, object_type, status FROM user_objects; OBJECT_NAME OBJECT_TYPE STATUS -------------------- ------------------- ------- TRIGGER_TEST_API PACKAGE VALID TRIGGER_TEST TABLE VALID TRIGGER_TEST_BS_TRG TRIGGER VALID TRIGGER_TEST_BR_TRG TRIGGER VALID TRIGGER_TEST_AR_TRG TRIGGER VALID TRIGGER_TEST_AS_TRG TRIGGER VALID 6 rows selected.SQL UPDATE trigger_test SET id = id; BEFORE STATEMENT - UPDATE BEFORE EACH ROW - UPDATE (new.id=2 old.id=2) AFTER EACH ROW - UPDATE (new.id=2 old.id=2) BEFORE EACH ROW - UPDATE (new.id=1 old.id=1) AFTER EACH ROW - UPDATE (new.id=1 old.id=1) AFTER STATEMENT - UPDATE 2 rows updated.CREATE OR REPLACE TRIGGER my_test_trg BEFORE INSERT OR UPDATE OR DELETE ON my_table FOR EACH ROW BEGIN -- Flags are booleans and can be used in any branching construct. If you need some code to perform an operation that needs to commit, regardless of the current transaction, you should put it in a stored procedure defined as an autonomous transaction, shown here.CASE WHEN INSERTING THEN -- Include any code specific for when the trigger is fired from an INSERT. WHEN UPDATING THEN -- Include any code specific for when the trigger is fired from an UPDATE. WHEN DELETING THEN -- Include any code specific for when the trigger is fired from a DELETE. DML triggers have four basic timing points for a single table. With the exception of Compound Triggers, the triggers for the individual timing points are self contained and can't automatically share state or variable information.

Leave a Reply