Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Writing stored procedures : Using the OpenEdge SQL Java classes : Setting SQL statement input parameters and procedure result set fields to null
 
Setting SQL statement input parameters and procedure result set fields to null
Both the setParam method and set method take objects as their value arguments. You can pass a NULL reference directly to the method or pass a variable that has been assigned the null value.
The following example uses both techniques to set an SQL input parameter to NULL.
CREATE TABLE t1 (
c1 INTEGER,
c2 INTEGER,
c3 INTEGER);
CREATE PROCEDURE test_nulls( )
BEGIN
Integer pvar_int ;
pvar_int = null ;
SQLIStatement insert_t1 = new SQLIStatement
( "INSERT INTO t1 (c1, c2, c3) values (?,?,?) ");
// Set to non-null value
insert_t1.setParam(1, new Integer(1));
// Set directly to null
insert_t1.setParam(2, null);
// Set indirectly to null
insert_t1.setParam(3, pvar_int);
insert_t1.execute();
END