Progress
Programming
Handbook


DELETE Schema Trigger Example

This is an example of a DELETE schema trigger procedure:

p-dltcst.p
TRIGGER PROCEDURE FOR DELETE OF customer. 
  FOR EACH invoice OF customer: 
    IF invoice.amount > invoice.total-paid + invoice.adjustment THEN DO: 
    MESSAGE "Outstanding unpaid invoice exists. Cannot delete.". 
    RETURN ERROR. 
    END. 
END. 
FOR EACH order OF customer: 
  DELETE order. 
END. 

This DELETE trigger executes whenever you try to delete a customer record. The procedure finds outstanding invoices of the customer and checks to see if they are paid. If not, the trigger returns an error and the deletion fails. If so, the trigger deletes all of the customer’s orders.

The delete trigger executes before Progress evaluates validation criteria, so you can perform any actions that would allow the delete to pass the validation.

All DELETE triggers execute before Progress actually deletes the record and can therefore refer to fields in the deleted record.

Even though Progress has not yet deleted the record when the DELETE trigger executes, any FIND request in the same application for that record fails. Since the record is in the process of being deleted, Progress treats it as though it is not available.


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