Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Writing stored procedures : Using the OpenEdge SQL Java classes : setParam method: pass input values to SQL statements
 
setParam method: pass input values to SQL statements
The setParam method sets the value of an SQL statement's parameter marker to the specified value (a literal value, a procedure variable, or a procedure input parameter).
The setParam method takes two arguments. This is the syntax for setParam:
Syntax
setParam ( marker_num , value ) ;
marker_num
Specifies the ordinal number of the parameter marker in the SQL statement that is to receive the value as an integer. 1 denotes the first parameter marker, 2 denotes the second, n denotes the nth.
value
Specifies a literal, variable name, or input parameter that contains the value to be assigned to the parameter marker.
The following example shows a segment of a stored procedure that uses setParam to assign values from two procedure variables to the parameter markers in an SQL INSERT statement. When the procedure executes, it substitutes the value of the cust_number procedure variable for the first parameter marker and the value of the cust_name variable for the second parameter marker.
SQLIStatement insert_cust = new SQLIStatement (
"INSERT INTO customer VALUES (?,?) ");
insert_cust.setParam (1, cust_number);
insert_cust.setParam (2, cust_name);