Environment
Situation
Sybase can execute stored procedures in two distinct modes: chained and unchained. Depending upon the configuration of the IDM Driver for JDBC and stored procedures in a database, various problems can arise. This topic is sufficiently nuanced to warrant a detailed discussion of chain modes and their impact on the IDM Driver for JDBC, hereafter referred to as "the driver”.
Resolution
Error 7112: Stored procedure'x'may be run only in chained transaction mode.
Another possibility is that the transaction type has been overridden to'manual' in policy.
NOTE: If you setuse-manual-transactionsto false, all transactions will consist of, at most, one statement.
Using Stored Procedure sp_proxmode
The preferred way to avoid errors 7112 and 7113 is to alter all stored procedures invoked directly or indirectly (via triggers, for example) by the driver to run in both chained and unchained mode. To alter a procedure, invoke thesp_procxmodewith two arguments: the procedure name and the mode.
The following is an example of how to invoke said procedure from the isql command line client:
sp_procxmodemy_procedure, anymode
GO
Of course, not all customers will be willing to alter stored procedure modes. Altering a procedure's mode may alter its runtime behavior which could alter the behavior of other applications that invoke the procedure.
Chained vs. Unchained Mode
Unchained mode is Sybase's native way of executing SQL. A second mode, chained mode, was later added to make the database compatible w/ SQL standards.
In summary:
chained = SQL-compatible mode
unchained = Sybase native mode
In Summary:
Connection.setAutoCommit(true) = switch to unchained mode
Connection.setAutoCommit(false) = switch chained mode
The driver will invokeConnection.setAutoCommit(false)(i.e., enter chained mode) if the parameteruse-manual-transactionsis set to true. This is the normal processing mode for all statements except SELECT statements and SQL embedded in policy where the transaction type is set to'manual' (https://www.novell.com/documentation/idmdrivers/jdbc/data/af899ky.html#af8bdjt). It's in this state that any unchained stored procedures invoked directly or indirectly by the driver will yield the 7113 error.
Managing Transactions in Policy
Useful Links
Transact-SQL User's Guide: Selecting the transaction mode and isolation level
http://manuals.sybase.com/onlinebooks/groupas/asg1250e/sqlug/@Generic__BookTextView/53713;pt=53001