Progress
Language Tutorial
for Character


Triggers and Database Events

In Chapter 3, you learned about events and triggers. These triggers and events are called user-interface events and user-interface triggers. Tables and fields in a Progress database can receive a different type of event known as database events. Tables and fields respond to these events with a different type of trigger known as a database trigger.

When discussing database triggers, it’s also important to distinguish two types: schema triggers and session triggers. A schema trigger is a database trigger stored in the schema of a database. A session trigger is a database trigger used in code.

There are five database events, as described in Table 4–6.

Table 4–6: Database Events 
Event
Object Type
Description
CREATE
Table
Executes on creation of a new record. For example, use a CREATE trigger to insert data, like the current date, into record fields.
DELETE
Table
Executes on deletion of a record. For example, use a DELETE trigger to prompt the user to confirm the deletion.
FIND
Table
Executes when Progress locates a record that satisfies a search request. For example, use a FIND trigger to increment a field that keeps track of how many times a record has been accessed.
WRITE
Table
Executes whenever a record is written to the database. For example, use a WRITE trigger to make a copy of the old record before writing the new data.
ASSIGN
Field
Executes when an individual field has new data written to it. For example, use an ASSIGN trigger to make a copy of old data before copying new data to a field.

To specify a trigger, access the appropriate table or field dialog box and choose the Triggers button. Figure 4–8 shows the Table Triggers dialog box for the Customer table.

Figure 4–8: Table Triggers Dialog Box

The tutorial doesn’t cover how to write and implement database triggers. Still it’s important to know about them. Database triggers give 4GL programmers the ability to define custom default behaviors and business rules for your data. The database then becomes a central storage place for these rules.

For information on using database trigger dialog boxes, the Progress Basic Development Tools manual.


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