Progress
Programming
Handbook
Database Events
Database triggers associate a table or field with a database event. When the event occurs, the trigger executes.
Progress does not provide events for all database actions. For example, although you can dump database definitions from a database, you cannot write a trigger for a DUMP event, because Progress does not provide a DUMP event.
However, Progress does provides replication-related triggers in addition to standard triggers for certain events. Replication-related triggers help you implement database replication.
The database events that Progress supports, along with the standard triggers and replication-related triggers are:
- CREATE — When Progress executes a CREATE or INSERT statement for a database table, Progress creates the record, fires all applicable CREATE triggers, and then fires all applicable REPLICATION–CREATE triggers.
- DELETE — When Progress executes a DELETE statement for a database table, Progress fires all applicable DELETE triggers, fires all applicable REPLICATION–DELETE triggers, validates the delete, and then performs the delete.
- FIND — When Progress reads a record in a database table using a FIND or GET statement or a FOR EACH loop, Progress fires all applicable FIND triggers. FIND triggers fire only for records that completely satisfy the full search condition, such as a WHERE clause specifies. FIND triggers do not fire in response to the CAN–FIND function.
If a FIND trigger fails, Progress behaves as though the record had not met the search criteria. If the FIND is within a FOR EACH block, Progress simply proceeds to the next record.
If your application uses the BREAK option of the PRESELECT phrase (which forces Progress to retrieve two records at a time, so it can find the break), Progress executes the FIND trigger twice during the first FIND, which is actually two FINDs in succession. Thereafter, Progress looks one record ahead of the record currently in the record buffer, and executes the FIND trigger before it places the next record in the buffer.
- WRITE — When Progress changes the contents of a record and validates it for a database table, Progress first fires all applicable WRITE triggers and then all applicable REPLICATION–WRITE triggers. Progress automatically validates a record when releasing it. You can also use the VALIDATE statement to explicitly validate a record. In either case, WRITE triggers execute before the validation occurs (so WRITE triggers can correct values and do more sophisticated validation). Progress might execute the WRITE triggers for a single record more than once before it writes the record to the database (if it validates the record more than once and you modify the record between validations).
- ASSIGN — When Progress updates a field in a database record, Progress fires all applicable ASSIGN triggers. Unlike the other database events, this trigger monitors a specific field rather than a table. ASSIGN triggers execute when the contents of the associated field are modified. The trigger procedure executes at the end of a statement that assigns a new value to the field and after any necessary re-indexing. If the statement contains several field assignments (for example, UPDATE name city st), Progress fires each applicable ASSIGN trigger at the end of the statement. If any trigger fails, Progress undoes the statement (unless the code specifies NO–UNDO).
For more information on replication-related triggers and database replication, see the Progress Database Administration Guide and Reference.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |