Neoview Guide to Stored Procedures in Java (R2.3, R2.4)

Result Sets
Result sets are an ordered set of open cursors that the SPJ method returns to the calling application
in java.sql.ResultSet[] parameter arrays. The java.sql.ResultSet[] parameters do
not correspond with SQL parameters, so you must not include them in the parameter argument
list of a CALL statement.
The calling application can retrieve multiple rows of data from the java.sql.ResultSet[]
parameters. For information about how to process result sets in different applications, see:
“Returning Result Sets in NCI” (page 67)
“Returning Result Sets in an ODBC Client Application” (page 68)
“Returning Result Sets in a JDBC Client Application” (page 69)
Calling SPJs in NCI
In NCI, you can invoke an SPJ by issuing a CALL statement directly or by preparing and executing
a CALL statement.
Use named or unnamed parameters anywhere in the argument list of an SPJ invoked in NCI. A
named parameter is set by the SET PARAM command, and an unnamed parameter is set by the
USING clause of the EXECUTE statement.
You must use a parameter for an OUT or INOUT parameter argument. NCI displays all output
parameter values and result sets after you issue the CALL statement. The procedure call does
not change the value of a named parameter that you use as an OUT or INOUT parameter.
For more information about named and unnamed parameters, see the Neoview Command Interface
(NCI) Guide.
Using Named Parameters
In an NCI session, invoke the SPJ named TOTALPRICE, which has two IN parameters and one
INOUT parameter. This SPJ accepts the quantity, shipping speed, and price of an item, calculates
the total price, including tax and shipping charges, and returns the total price. For more
information, see the “TOTALPRICE Procedure” (page 84).
Set the input value for the INOUT parameter by entering a SET PARAM command before calling
the SPJ:
SQL>set param ?p 10;
SQL>call sales.totalprice(23, 'standard', ?p);
The CALL statement returns the total price of the item:
*** WARNING[11217] Java execution: Data overflow occurred while retrieving data
at parameter position 3. Value is truncated.
p
--------------------
253.96
--- SQL operation complete.
The value of the named parameter, ?p, changes from 10 to the returned value, 253.96:
SQL>show param
p 253.96
Using Unnamed Parameters
In an NCI session, invoke the SPJ named TOTALPRICE by preparing and executing a CALL
statement. The INOUT parameter accepts a value that is set by the USING clause of the EXECUTE
statement and returns the total price:
SQL>prepare stmt1 from call sales.totalprice(50, 'nextday',?);
--- SQL command prepared.
66 Executing SPJs