Progress
Programming
Handbook


Session Triggers

You define a database session trigger within a Progress procedure. The trigger persists while the procedure that defined it and any subprocedures are running. A session trigger takes effect when Progress encounters it at run time. It remains in effect until the defining procedure terminates. However, if a subprocedure contains another trigger for the same table/event or field/event pair, the trigger in the subprocedure overrides the original trigger. After the subprocedure returns, the original trigger goes back into effect.

NOTE: There are no session triggers related to database replication. In other words, Progress does not support:

ON REPLICATION-WRITE of Customer DO: 
  /* some action */  
  END. 
/* Progress does not support this */ 

A session trigger has access to the defining procedure’s context, regardless of which procedure initiates the event that causes it to execute. The session trigger can refer to the defining procedure’s variables and other local objects.

The following is the syntax for session database triggers.

SYNTAX
ON event OF object [ reference-clause ] 
  [ OVERRIDE ] { trigger-block | REVERT } 

event

The event parameter is a CREATE, WRITE, DELETE, FIND, or ASSIGN event.

object

The object for table-related events (CREATE, DELETE, FIND, or WRITE) has this syntax:

SYNTAX
OF table 

The object-reference for a field-related event (ASSIGN) has this syntax:

SYNTAX
OF table.field 

reference-clause

The reference-clause for a table related event (WRITE triggers only) has this syntax:

SYNTAX
[ NEW [ BUFFER ] buffer1 ] [ OLD [ BUFFER ] buffer2 ] 

Use reference-clause for the WRITE trigger if you want to refer to the values in the updated record before and after the record changed. The reference-clause uses the same syntax and rules as the schema database WRITE trigger.

The reference clause for a field-related event (ASSIGN) has this syntax:

SYNTAX
OLD [ VALUE ] parameter 
  [   COLUMN-LABEL label 
   | FORMAT string 
   | INITIAL constant 
   | LABEL string 
   | NO-UNDO 
  ] 

Session ASSIGN triggers always have access to the table’s buffer; the referenceclause allows access to the old value of the trigger field.

OVERRIDE

The OVERRIDE option causes the session trigger to execute instead of the schema trigger, if the schema trigger is defined with OVERRIDE=YES. If you attempt to OVERRIDE a schema trigger defined as OVERRIDE=NO, Progress returns a runtime error.

trigger-block

A single 4GL statement or a DO block. The trigger block executes whenever the specified event occurs. The context of the block of 4GL code is similar to that of internal procedures. In fact, this code executes when the event occurs, almost as if it were an internal procedure. (See "Block Properties," for information on internal procedures.)

REVERT

The REVERT option cancels the trigger for the given event/table or event/field pair and reactivates any previously defined trigger for that event/object pair defined in a parent procedure. If no previously defined trigger exists, the trigger for the event/object pair is effectively disabled.


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