SQL/MX 3.2.1 Guide to Stored Procedures in Java (H06.26+, J06.15+)
5 Invoking SPJs in NonStop SQL/MX
This section describes how to execute SPJs and assumes that you have already registered the SPJs
in NonStop SQL/MX. For information about registering an SPJ, see Chapter 4: Registering SPJs
in NonStop SQL/MX.
This section covers these topics:
• Calling an SPJ (page 71)
• Using the CALL Statement (page 72)
• 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)
Calling an SPJ
The CALL statement invokes an SPJ in NonStop SQL/MX. You can issue the CALL statement from
any of these applications or interfaces that call NonStop SQL/MX:
• SQL/MX conversational interface (MXCI)
• JDBC/MX programs
• Embedded SQL programs in C, C++, or COBOL
• NonStop ODBC/MX clients
You can use the CALL statement only as a stand-alone SQL statement. You cannot use the CALL
statement inside a compound statement or with rowsets.
Required Privileges for Calling an SPJ
To execute the CALL statement, you must have the EXECUTE privilege on the procedure. For more
information, see Granting Privileges for Invoking SPJs (page 83).
Effect of Calling an SPJ
When you issue a CALL statement, the SPJ method of the invoked SPJ executes inside a JVM within
an SPJ environment. For more information, see the Effect of Invoking an SPJ (page 22).
CAUTION: NonStop SQL/MX does not maintain the Java class file that contains the SPJ method.
NonStop SQL/MX records only a reference to the location of the Java class file in system metadata.
Subsequent changes to the Java class file after you register an SPJ might result in run-time errors
when you try to execute it. For guidelines on how to alter an SPJ, see Altering an SPJ and Its Java
Class (page 68).
Transaction Behavior
A CALL statement automatically initiates a transaction if there is no active transaction. An SPJ
method invoked by a CALL statement usually inherits the transaction from its caller, except when
jdbcmx.transactonMode is set to internal. For more information, see the Effect of the
jdbcmx.transactionMode Property (page 72).
Transaction Statements or Methods in an SPJ Method
You can start transactions within a stored procedure by performing the following steps:
Calling an SPJ 71










