Wednesday, March 24, 2010

Sunday, March 7, 2010

Sybase Stored procedures Chained , UnChained mode

The terms Chained , UnChained here refer to how the transactions are handled.
Chained mode [ the ANSI SQL standard ] - In this mode the BEGIN TRANSACTION is always implicitly called by the server when the client calls the server. the client has to explicitly call the COMMIT or ROLLBACK to end the transaction.
So in Chained mode there is only explicit call to close tx but no explicit begin tx.
when using JDBC-Chained mode - Connection.setAutoCommit(false)

UnChained Mode - [The Sybase way]-Here there has to be both explicit BEGIN TX and COMMIT/ROLLBACK TX to close it.
when using JDBC - Unchained mode - Connection.setAutoCommit(true):
This mode is the default in sybase.


When stored procs are created in sybase the adaptive Server tags all procedures with the transaction mode ("chained" or "unchained") of the session in which they are created.

This helps avoid problems associated with transactions that use one mode to invoke transactions that use the other mode. A stored procedure tagged as "chained" is not executable in sessions using unchained transaction mode, and vice versa.

Triggers are executable in any transaction mode. Since they are always called as part of a data modification statement, either they are part of a chained transaction (if the session uses chained mode) or they maintain their current transaction mode.

sp_procxmode - to display or change the transaction mode of stored procedures.

more here

Identity Gaps in Sybase

Strange issue I noticed with id column values in the db tables.
they seem to take huge leaps suddenly!
sybase manual
more info here