SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)
For more information about MXCI parameters, see the SQL/MX Reference Manual.
Using MXCI Named Parameters
In an MXCI 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 Sales Class (page 107).
Set the input value for the INOUT parameter by entering a SET PARAM command before calling
the SPJ:
SET PARAM ?p 10;
CALL samdbcat.sales.totalprice(23, 'standard', ?p);
The CALL statement returns the total price of the item:
PRICE
---------------------
253.96
--- SQL operation complete.
The value of the MXCI named parameter, ?p, remains 10.
Using MXCI Unnamed Parameters
In an MXCI 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:
SET SCHEMA samdbcat.sales;
PREPARE stmt1 FROM CALL totalprice(50,'nextday',?);
EXECUTE stmt1 USING 2.25;
The output of the prepared CALL statement is:
PRICE
---------------------
136.77
--- SQL operation complete.
In an MXCI session, invoke the SPJ named TOTALPRICE again by preparing and executing a CALL
statement in which all three parameters accept values that are set by the USING clause of the
EXECUTE statement. The INOUT parameter returns the total price:
PREPARE stmt2 FROM CALL totalprice(?,?,?);
EXECUTE stmt2 USING 3, 'economy', 16.99;
The output of the prepared CALL statement is:
PRICE
---------------------
57.12
--- SQL operation complete.
Invoking SPJs in MXCI 75










