OLDROW and NEWROW objects: passing values to triggers
- Last Updated: February 11, 2026
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The OLDROW and NEWROW objects
allow SQL to pass row values as input parameters to the stored procedure
in a trigger that executes once for each affected row. If the CREATE
TRIGGER statement contains the REFERENCING clause,
the SQL server implicitly instantiates an OLDROW or NEWROW object
(or both, depending on the arguments to the REFERENCING clause)
when it creates the Java class.
This allows the Java code in the snippet to use the getValue method
of those objects to retrieve values of columns in rows affected
by the trigger event and store them in procedure variables, and
use the setValue method of those objects to set the values to be
stored in the database before the trigger event. For example:
- The
OLDROWobject contains values of a row as it exists in the database before an update or delete operation. It is instantiated when triggers specify anUPDATE...REFERENCING OLDROWorDELETE...REFERENCING OLDROWclause. It is meaningless and not available for insert operations. ThegetValuemethod is valid onOLDROWbefore or after an update or delete and thesetValuemethod is not valid onOLDROWat all. - The
NEWROWobject contains values of a row as specified in anINSERTorUPDATEstatement. It is instantiated when triggers specify anUPDATE...REFERENCING NEWROWorINSERT...REFERENCING NEWROWclause. It is meaningless and not available for delete operations. ThegetValuemethod is valid onNEWROWbefore or after an update or insert and thesetValuemethod is only valid onNEWROWbefore insert or update.
UPDATE is the only triggering statement that
allows both NEWROW and OLDROW in
the REFERENCING clause.
Triggers use the OLDROW.getValue and NEWROW.getValue methods
to assign a value from a row being modified to a procedure variable.
The format and arguments for getValue are the same
as in other OpenEdge SQL Java classes. This is the syntax for getValue:
|
- col_num
- Specifies the integer column number of the affected row.
getValueretrieves the value in the column denoted by col_num.1denotes the first column of the table that the trigger is for.2denotes the second, n denotes the nth. - sql_data_type
- Specifies the corresponding SQL data type. For a complete list of appropriate data types, see the Mapping between SQL and Java data types table.