Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Extended error data [Table of Contents] Example programs

Open Client Client-Library/C Reference Manual

[-] Chapter 2 Topics
[-] Error handling
[-] Server transaction states

Server transaction states

Server transaction state information is useful when an application needs to determine the outcome of a transaction.

The following table lists the symbolic values that represent transaction states:

Transaction states

Symbolic value

Meaning

CS_TRAN_IN_PROGRESS

A transaction is in progress.

CS_TRAN_COMPLETED

The most recent transaction completed successfully.

CS_TRAN_STMT_FAIL

The most recently executed statement in the current transaction failed.

CS_TRAN_FAIL

The most recent transaction failed.

CS_TRAN_UNDEFINED

A transaction state is not currently defined.

Retrieving transaction states in mainline code

In mainline code, an application retrieves a transaction state by calling ct_res_info with type as CS_TRANS_STATE:

CS_RETCODE      ret;
 CS_INT          outlen;
 CS_INT          trans_state;
ret = ct_res_info (cmd, CS_TRANS_STATE,
     &trans_state, CS_UNUSED, &outlen)

ct_res_info sets trans_state to one of the symbolic values listed in Table 2-21.

Transaction state information is available only for CS_COMMAND structures with pending results or an open cursor. That is, transaction state information is available if an application's last call to ct_results returned CS_SUCCEED.

Transaction state information is guaranteed to be correct only after ct_results sets *result_type to CS_CMD_DONE, CS_CMD_SUCCEED, or CS_CMD_FAIL.

Retrieving transaction states in a server message callback

An application retrieves transaction states inside a server message callback only if extended error data is available.

Within a server message callback, Client-Library indicates that extended error data is available by setting the CS_HASEED bit of the status field of the CS_SERVERMSG structure describing the message.

If extended error data is available, the application retrieves the current transaction state by:

  1. Retrieving the CS_COMMAND with the extended error data by calling ct_con_props with property as CS_EED_CMD.

  2. Calling ct_res_info with type as CS_TRANS_STATE. ct_res_info sets its *buffer parameter to one of the symbolic values listed in Table 2-21.


Extended error data [Table of Contents] Example programs