ct_diag

Description

Manage inline error handling.

Syntax

CS_RETCODE ct_diag(connection, operation, type, index,
               buffer)
CS_CONNECTION    *connection;
CS_INT                      operation;
CS_INT                      type;
CS_INT                      index;
CS_VOID                   *buffer;

Parameters

connection

A pointer to a CS_CONNECTION structure. A CS_CONNECTION structure contains information about a particular client/server connection.

operation

The operation to perform. Table 3-20 lists the symbolic values for operation.

type

Depending on the value of operation, type indicates either the type of structure to receive message information, the type of message on which to operate, or both. Table 3-19 lists the symbolic values for type:

Table 3-19: Values for ct_diag type parameter

Value of type

Meaning

SQLCA_TYPE

A SQLCA structure.

SQLCODE_TYPE

A SQLCODE structure, which is a long integer.

SQLSTATE_TYPE

A SQLSTATE structure, which is a six-element character array.

CS_CLIENTMSG_TYPE

A CS_CLIENTMSG structure. Also used to indicate Client-Library messages.

CS_SERVERMSG_TYPE

A CS_SERVERMSG structure. Also used to indicate server messages.

CS_ALLMSG_TYPE

Client-Library and server messages.

index

The index of the message of interest. The first message has an index of 1, the second an index of 2, and so forth.

If type is CS_CLIENTMSG_TYPE, then index refers to Client-Library messages only. If type is CS_SERVERMSG_TYPE, then index refers to server messages only. If type is CS_ALLMSG_TYPE, then index refers to Client-Library and server messages combined.

buffer

A pointer to data space.

Depending on the value of operation, buffer can point to a structure or a CS_INT.

Returns

ct_diag returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

ct_diag returns CS_FAIL if the original error has made the connection unusable.

CS_NOMSG

The application attempted to retrieve a message whose index is higher than the highest valid index. For example, the application attempted to retrieve message number 3, but only 2 messages are queued.

CS_BUSY

An asynchronous operation is already pending for this connection. For more information, see “Asynchronous programming”.

Common reasons for a ct_diag failure include:

Usage

Table 3-20: Summary of ct_diag parameters

Value of operation

Resulting action

Type is

Index is

Buffer is

CS_INIT

Initializes inline error handling.

CS_UNUSED

CS_UNUSED

NULL

CS_MSGLIMIT

Sets the maximum number of messages to store.

CS_CLIENTMSG_TYPE to limit Client-Library messages only.

CS_SERVERMSG_TYPE to limit server messages only.

CS_ALLMSG_TYPE to limit the total number of Client-Library and server messages combined.

CS_UNUSED

A pointer to an integer value.

CS_CLEAR

Clears message information for this connection.

If buffer is not NULL and type is not CS_ALLMSG_TYPE, ct_diag also clears the *buffer structure by initializing it with blanks and/or NULLs, as appropriate.

Any valid type value.

If type is CS_CLIENTMSG_TYPE, ct_diag clears Client-Library messages only.

If type is CS_SERVERMSG_TYPE, ct_diag clears server messages only.

If type has any other valid value, ct_diag clears both Client-Library and server messages.

CS_UNUSED

A pointer to a structure whose type is defined by type, or NULL.

CS_GET

Retrieves a specific message.

Any valid type value except CS_ALLMSG_TYPE.

If type is CS_CLIENTMSG_TYPE, a Client-Library message is retrieved into a CS_CLIENTMSG structure.

If type is CS_SERVERMSG_TYPE, a server message is retrieved into a CS_SERVERMSG structure.

If type has any other valid value, then either a Client-Library or server message is retrieved.

The one-based index of the message to retrieve.

A pointer to a structure whose type is defined by type.

CS_STATUS

Returns the current number of stored messages.

CS_CLIENTMSG_TYPE to retrieve the number of Client-Library messages.

CS_SERVERMSG_TYPE to retrieve the number of server messages.

CS_ALLMSG_TYPE to retrieve the total number of Client-Library and server messages combined.

CS_UNUSED

A pointer to an integer variable.

CS_EED_CMD

Sets *buffer to the address of the CS_COMMAND structure containing extended error data.

CS_SERVERMSG_TYPE

The one-based index of the message for which extended error data is available.

A pointer to a pointer variable.


Initializing inline error handling


Clearing messages


Retrieving messages


Limiting messages


Retrieving the number of messages


Getting the CS_COMMAND for extended error data


Sequenced messages and ct_diag

See also

“Error handling” “CS_CLIENTMSG structure”, “CS_SERVERMSG structure”, “SQLCA structure”, “SQLCODE structure”, “SQLSTATE structure”, ct_callback, ct_options