SQL$HELP72.HLB  —  ALTER  TRIGGER  Examples
    Example 1: Disabling a Trigger

    The following example shows that while the EMPLOYEE_ID_CASCADE_
    DELETE trigger is enabled, deleting a record from EMPLOYEES
    causes the corresponding record in JOB_HISTORY to be deleted.
    After the trigger is disabled, a deletion from EMPLOYEES does not
    trigger a deletion from the JOB_HISTORY table.

    SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';
     EMPLOYEE_ID   JOB_CODE   JOB_START     JOB_END       DEPARTMENT_CODE
       SUPERVISOR_ID
     00164         DMGR       21-Sep-1981   NULL          MBMN
       00228
     00164         SPGM        5-Jul-1980   20-Sep-1981   MCBM
       00164
    2 rows selected
    SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164';
    1 row deleted
    SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';
    0 rows selected
    SQL> ROLLBACK;
    SQL> ALTER TRIGGER EMPLOYEE_ID_CASCADE_DELETE DISABLE;
    SQL> COMMIT;
    SQL> DISCONNECT DEFAULT;
    .
    .
    .
    SQL> DELETE FROM EMPLOYEES WHERE EMPLOYEE_ID ='00164';
    1 row deleted
    SQL> SELECT * FROM JOB_HISTORY WHERE EMPLOYEE_ID='00164';
    EMPLOYEE_ID   JOB_CODE   JOB_START     JOB_END       DEPARTMENT_CODE
       SUPERVISOR_ID
     00164         DMGR       21-Sep-1981   NULL          MBMN
       00228
     00164         SPGM        5-Jul-1980   20-Sep-1981   MCBM
       00164
    2 rows selected
Close Help