SQL/MX Guide to Stored Procedures in Java (G06.24+, H06.03+)

Invoking SPJs in NonStop SQL/MX
HP NonStop SQL/MX Guide to Stored Procedures in Java523727-004
5-2
Effect of Calling an SPJ
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 on page 1-8.
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 on page 5-3.
Transaction Statements or Methods in an SPJ Method
An SPJ method cannot contain JDBC transaction methods, such as
Connection.commit() or Connection.rollback(), or SQL transaction
statements, such as COMMIT WORK or ROLLBACK WORK. Instead, use transaction
control statements in an application that calls an SPJ and allow the calling application
to manage transactions.
Committing or Rolling Back a Transaction
In an application, the failure of a CALL statement does not always automatically abort
a transaction:
When AUTOCOMMIT is ON during a system-initiated transaction, errors that occur
during the execution of a CALL statement cause NonStop SQL/MX to roll back the
transaction automatically, including database operations performed by the SPJ
method, at the end of statement execution.
When AUTOCOMMIT is OFF during a system-initiated or user-defined transaction,
errors that occur during the execution of a CALL statement do not cause NonStop
SQL/MX to roll back the transaction automatically.
To ensure an atomic unit of work in a user-defined transaction or when autocommit is
OFF during a system-defined transaction, you should explicitly commit the transaction
in the calling application when the transaction is successful and roll back the
transaction in the calling application when an error occurs. For more information about
transaction management, see the SQL/MX Reference Manual.
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
on page 4-13.