TRIGGER PROCEDURE FOR event OF object options
|
TRIGGER PROCEDURE FOR CREATE OF table
|
TRIGGER PROCEDURE FOR DELETE OF table
|
TRIGGER PROCEDURE FOR FIND OF table
|
TRIGGER PROCEDURE FOR WRITE OF table
NEW BUFFER buffer-name1 OLD BUFFER buffer-name2 |
TRIGGER PROCEDURE FOR ASSIGN
OF table .field NEW VALUE value1 AS data-type LIKE db-field COLUMN-LABEL label FORMAT format-string INITIAL constant LABEL label-string NO-UNDO OLD VALUE value2 AS data-type LIKE db-field COLUMN-LABEL label FORMAT format-string INITIAL constant LABEL label-string NO-UNDO |
TRIGGER PROCEDURE FOR WRITE OF Customer OLD BUFFER oldCustomer.
/* Variable Definitions */ DEFINE VARIABLE ix AS INTEGER NO-UNDO. DEFINE VARIABLE Outstanding AS INTEGER NO-UNDO. /* Check to see if the user changed the Customer Number */ IF Customer.CustNum <> oldCustomer.CustNum AND oldCustomer.CustNum <> 0 THEN DO: /* If the user changed the Customer Number, find all related Orders and change their Customer numbers. */ FOR EACH order OF oldCustomer: Order.CustNum = Customer.CustNum. ix = ix + 1. END. IF ix > 0 THEN MESSAGE ix "Orders changed to reflect the new Customer number!". END. /* Ensure that the Credit Limit value is always greater than the sum of this Customer's outstanding balance */ FOR EACH Order OF Customer NO-LOCK: FOR EACH OrderLine OF Order NO-LOCK: Outstanding = Outstanding + (OrderLine.Qty * OrderLine.Price). END. END. FOR EACH Invoice OF Customer NO-LOCK: Outstanding = Outstanding + (Invoice.Amount - (Invoice.TotalPaid + Invoice.Adjustment)). END. IF Customer.CreditLimit < Outstanding THEN DO: MESSAGE "This Customer has an outstanding balance of: " Outstanding ". The Credit Limit MUST exceed this amount!". RETURN ERROR. END. |