Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Working with triggers : Assigning null values from SQL OLDROW and NEWROW statement objects: the OLDROW.isNULL method and NEWROW.isNULL
 

Assigning null values from SQL OLDROW and NEWROW statement objects: the OLDROW.isNULL method and NEWROW.isNULL

If the value of a column in a statement object is the SQL NULL value, then the getValue method will return a Java "null" value. The null value can be dangerous in Java, and cause runtime exceptions.
You must always check whether a value is null before attempting to assign the value from a statement object to a trigger's Java variable or to a new SQL statement input parameter. The OLDROW and NEWROW classes provide the isNULL method for this purpose.
The following example illustrates using the isNULL method:
If (OLDROW.isNULL(1))
qryStrBuf.append("StartDate is null " + " AND ");
else
qryStrBuf.append("StartDate = '" + OLDROW.getValue(1,0).toString() + "' AND ");
col_num
Specifies the integer column number of the affected row. getValue retrieves the value in the column denoted by col_num. 1 denotes the first column of the table that the trigger is for. 2 denotes the second, n denotes the nth.