SQL/MX Programming Manual for Java

SQLJ Programming
HP NonStop SQL/MX Programming Manual for Java523726-003
3-59
Calling Stored Procedures in Java
Calling Stored Procedures in Java
You can invoke stored procedures in Java (SPJs) in an SQLJ program by using a
CALL statement in an SQLJ executable clause. However, it is more efficient to call the
underlying Java method directly from an SQLJ or Java program instead of using a
CALL statement.
The host variables and expressions in the CALL statement default to the IN parameter
mode. Therefore, explicitly code the INOUT and OUT arguments of the CALL
statement in the SQLJ source file.
For the syntax of the CALL statement, see the SQL/MX Reference Manual. For more
information about SPJs, see the SQL/MX Guide to Stored Procedures in Java.
Examples
This code invokes the SPJ named MONTHLYORDERS by using the CALL statement:
#sql { CALL samdbcat.sales.monthlyorders (:IN month,
:OUT orderNum )
};
This code invokes the underlying Java method of the MONTHLYORDERS procedure:
numMonthlyOrders(month, orderNum);