SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)
For an IN parameter argument, use one of these SQL expressions:
ExamplesType of Argument
CALL adjustsalary(202, 5.5, ?);
CALL dailyorders(DATE '2003-03-19', ?);
CALL totalprice(23,'nextday', ?param);
Literal
CALL dailyorders(CURRENT_DATE, ?);SQL function
(including CASE and CAST
expressions)
CALL adjustsalary(202,:percent * 0.25, :OUT newsalary);Arithmetic expression
CALL totalprice(23,'next' || 'day', ?param);Concatenation operation
CALL totalprice((SELECT qty_ordered
FROM odetail
Scalar subquery
WHERE ordernum=100210
AND partnum=5100),
'nextday', ?param);
CALL adjustsalary(:empnum, :percent,
:OUT newsalary);
Host variable
CALL adjustsalary(?, ?, ?);
CALL adjustsalary(?param1, ?param2, ?param3);
Dynamic parameter
Because an INOUT parameter passes a single value to and accepts a single value from an SPJ,
you can specify only host variables or dynamic parameters for INOUT parameter arguments in a
CALL statement.
Output Parameter Arguments
An SPJ returns values in OUT and INOUT parameters. Each OUT or INOUT parameter accepts
only one value from an SPJ. Any attempt to return more than one value to an output parameter
results in a Java exception. See Returning Output Values From the Java Method (page 50).
Specify OUT and INOUT parameter arguments as either host variables in a static CALL statement
(for example, :hostvar) or dynamic parameters in a dynamic CALL statement (for example, ?
or ?param).
The parameter arguments that you specify in a CALL statement depend on the application or
interface that calls the SPJ. For information about how to invoke SPJs in different applications, see:
• Invoking SPJs in MXCI (page 74)
• Invoking SPJs Statically in an Embedded SQL Program in C, C++, or COBOL (page 76)
• Invoking SPJs Dynamically in an Embedded SQL Program in C, C++, or COBOL (page 77)
• Invoking SPJs in a NonStop ODBC/MX Client (page 80)
• Invoking SPJs in a JDBC/MX Program (page 81)
Invoking SPJs in MXCI
In MXCI, you can invoke an SPJ by issuing a CALL statement directly or by preparing and executing
a CALL statement.
Use MXCI named or unnamed parameters anywhere in the argument list of an SPJ invoked in
MXCI. An MXCI named parameter is set by the SET PARAM command, and an MXCI unnamed
parameter is set by the USING clause of the EXECUTE statement.
You must use an MXCI parameter for an OUT or INOUT parameter argument. MXCI displays all
output parameter values after you issue the CALL statement. The procedure call does not change
the value of an MXCI named parameter that you use as an OUT or INOUT parameter.
74 Invoking SPJs in NonStop SQL/MX










