Triggers
- Last Updated: December 19, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
OpenEdge SQL triggers are written in Java. These triggers automatically run the user-defined
logic when DML events like INSERT, UPDATE, or
DELETE occur on a table or its fields.
Given that triggers can access the data in tables both internally and externally, they may potentially enable an unauthorized user to access sensitive data. However, DDM masks the data and prevents unauthorized access by users who lack the necessary DDM privileges.
Triggers also enable accessing the data of the affected rows in the form of
OLD or NEW database objects, either before or
after the DML action takes place. The SQL engine creates the OLD and
NEW objects internally during a DML event on the table. The
OLD and NEW objects refer to the masked values of
the DDM-configured fields if you do not have unmasking privileges over those fields.
Example
BEFORE UPDATE trigger event
when trigger logic tries to access a DDM-configured field.
|
Discount is a DDM-configured field. The
custTrigBfrUpd trigger creates an instance of the
OLDROW object using the REFERENCING OLDROW
clause. The OLDROW object references the value of the affected row
in the pub.customer table prior to the update operation on the
Name field of this table. When you run the
UPDATE statement without unmasking privileges on the
Discount field in the pub.customer table, the
BEFORE UPDATE trigger event causes the
getValue method to:- Retrieve the masked value of the
discountfield (column 15) from the row affected by the trigger event. -
Store this masked value in the procedure variable named
oldValue.
SQLIStatement class issues the INSERT
statement, which inserts the masked value from oldValue into the
pub.dumpCustInfoBfrUpd table. As a result, masked data is
displayed when you retrieve records from the pub.dumpCustInfoBfrUpd
table.
Discount field for the affected row into the
pub.dumpCustInfoBfrUpd table. UPDATE statement can update a DDM-configured field only
when you have unmasking privileges over that field; otherwise, it fails with an
error.