Release 10.1A: OpenEdge Development:
Basic Database Tools

> ## Table Triggers

> The Table Triggers option in the Modify Table dialog box allows you to define schema triggers for a table. If you choose Table Triggers, a window similar to the one shown in Figure 9–3 appears.

> Figure 9–3: Table Triggers dialog box

> The Table Triggers dialog box contains the following fields:

> - Overridable?

> Specifies whether a session trigger can override the schema trigger. The default value is no. See OpenEdge Development: Progress 4GL Handbook for more information about schema and session triggers.

> - Check CRC?

> Specifies whether the database engine verifies the cyclical redundancy check (CRC) code. The default value is yes. When the database engine checks the code, it compares the stored CRC value of the procedure to the CRC of the trigger when it fires.

> - Trigger Programs

> Choose the database event for the trigger you want to create. Table 9–2 lists the available database events.

> Table 9–2: Table Trigger events
> Event | Description
> --- | ---
> CREATE | Specifies that the trigger executes every time a CREATE or INSERT statement executes for the table you are modifying.
> DELETE | Specifies that the trigger executes every time a DELETE statement executes for the table you are modifying.
> FIND | Specifies that the trigger executes every time a record in the table you are modifying is read using a FIND statement or a FOR EACH loop. Only records that satisfy the full search conditions (such as a WHERE clause) cause a FIND trigger to execute. The CAN-FIND statement does not cause a FIND trigger to execute.
> WRITE | Specifies that the trigger executes every time OpenEdge RDBMS validates a record. OpenEdge RDBMS automatically validates a record when it releases it. Note: OpenEdge RDBMS does not compare the new record with the old record when determining if it should fire the WRITE trigger. Even temporary changes to a table (as when a field is changed, then changed back to its original value) cause WRITE to fire. If it is necessary to handle this situation, use the NEW BUFFER and OLD BUFFER options in your trigger procedure to compare the values and detect a “dummy” change case.
> REPLICATION- CREATE | Specifies the trigger that executes immediately following the execution of the CREATE trigger, if specified. The purpose of the trigger is to replicate the creation of records to another database.
> REPLICATION- DELETE | Specifies the trigger that executes immediately following the execution of the DELETE trigger, if specified. The purpose of the trigger is to replicate the deletion of records to another database.
> REPLICATION- WRITE | Specifies the trigger that executes immediately following the execution of the WRITE trigger, if specified. The purpose of the trigger is to replicate updated records to another database.

> Press F6 to display the trigger code. Figure 9–4 shows an example of a delete trigger procedure.

> Figure 9–4: Trigger Code dialog box

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095