SQL$HELP_OLD72.HLB  —  ALTER  TRIGGER
    Enables, disables, or renames an existing trigger. Changes
    take place after the transaction containing the ALTER TRIGGER
    statement is committed.

1  –  Environment

    You can use the ALTER TRIGGER statement:

    o  In interactive SQL

    o  Embedded in host language programs to be precompiled

    o  As part of a procedure in an SQL module

    o  In dynamic SQL as a statement to be dynamically executed

2  –  Format

  ALTER TRIGGER <trigger-name> --+--> DISABLE --+----------------+----+->
                                 +--> ENABLE ---+                |    |
                                 +--> COMMENT IS -+-> 'string' -++    |
                                 |                +---- / ------+     |
                                 +--> RENAME TO <new-trigger-name> ---+
                                 +-------------------<----------------+

3  –  Arguments

3.1  –  COMMENT_IS

    Adds a comment about the trigger. SQL displays the text of the
    comment when it executes a SHOW statement. Enclose the comment
    in single quotation marks ( ') and separate multiple lines in a
    comment with a slash mark (/).

3.2  –  DISABLE

    Disables a previously enabled trigger.

3.3  –  ENABLE

    Enables a previously disabled trigger.

3.4  –  RENAME_TO

    Changes the name of the trigger being altered. See the RENAME for
    further discussion. If the new name is the name of a synonym then
    an error will be raised.

    The RENAME TO clause requires synonyms be enabled for this
    database. Refer to the ALTER DATABASE statement SYNONYMS ARE
    ENABLED clause. Note that these synonyms may be deleted if they
    are no longer used by database definitions or applications.

3.5  –  trigger-name

    The name of an existing trigger.

4  –  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