ct_res_info

Description

Retrieve current result set or command information.

Syntax

CS_RETCODE ct_res_info(cmd, type, buffer, buflen,
                outlen)
 
CS_COMMAND     *cmd;
CS_INT                  type;
CS_VOID               *buffer;
CS_INT                  buflen;
CS_INT                 *outlen;

Parameters

cmd

A pointer to the CS_COMMAND structure managing a client/server command.

type

The type of information to return. Table 3-54 lists the symbolic values for type.

buffer

A pointer to the space in which ct_res_info will place the requested information.

If buflen indicates that *buffer is not large enough to hold the requested information, ct_res_info sets *outlen to the length of the requested information and returns CS_FAIL.

buflen

The length, in bytes, of the *buffer data space, or CS_UNUSED if *buffer represents a fixed-length or symbolic value.

outlen

A pointer to an integer variable.

ct_res_info sets *outlen to the length, in bytes, of the requested information.

If the requested information is larger than buflen bytes, an application can use the value of *outlen to determine how many bytes are needed to hold the information.

Returns

ct_res_info returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_BUSY

An asynchronous operation is already pending for this connection. See “Asynchronous programming”.

ct_res_info returns CS_FAIL if the requested information is larger than buflen bytes, or if there is no current result set.

Examples

Example 1

This fragment from the rpc.c example program retrieves the number of columns in a fetchable result set:

          CS_INT   num_cols;
          /*
           ** Determine the number of columns in this result 
           ** set.
           */
           retcode = ct_res_info(cmd, CS_NUMDATA, #_cols,
                CS_UNUSED, NULL);
           if (retcode != CS_SUCCEED)
           {
                ...CODE DELETED...
           }

This fragment from the rpc.c example program retrieves the message identifier from a message result.

          CS_SMALLINT msg_id;
          ... ct_results has returned with a CS_MSG_RESULT
               result type ...
          case CS_MSG_RESULT:
                retcode = ct_res_info(cmd, CS_MSGTYPE,
                     (CS_VOID *)&msg_id, CS_UNUSED, NULL);
                if (retcode != CS_SUCCEED)
                {
                     ...CODE DELETED...
                }
                fprintf(stdout, "ct_result returned \ 
                     CS_MSG_RESULT where msg id = %d.\n", msg_id);
                break;

Usage

Table 3-54 summarizes ct_res_info usage.

Table 3-54: Summary of ct_res_info parameters

Value of type

Returned by ct_res_info into *buffer

Information available after ct_results sets its *result_type parameter to

*buffer Datatype

CS_BROWSE_INFO

CS_TRUE if browse-mode information is available; CS_FALSE if browse-mode information is not available.

CS_ROW_RESULT

CS_BOOL

CS_CMD_NUMBER

The number of the command that generated the current result set.

Any value

CS_INT

CS_MSGTYPE

An integer representing the ID of the message that makes up the current result set.

CS_MSG_RESULT

CS_USHORT

CS_NUM_COMPUTES

The number of compute clauses in the current command.

CS_COMPUTE_RESULT

CS_INT

CS_NUMDATA

The number of items in the current result set.

CS_COMPUTE_RESULT, CS_COMPUTEFMT_RESULT, CS_CURSOR_RESULT, CS_DESCRIBE_RESULT, CS_PARAM_RESULT, CS_ROW_RESULT, CS_ROWFMT_RESULT, CS_STATUS_RESULT

CS_INT

CS_NUMORDERCOLS

The number of columns specified in the order-by clause of the current command.

CS_ROW_RESULT

CS_INT

CS_ORDERBY_COLS

The select list ID numbers of columns specified in a the order by clause of the current command.

CS_ROW_RESULT

Array of CS_INT

CS_ROW_COUNT

The number of rows affected by the current command.

CS_CMD_DONE, CS_CMD_FAIL CS_CMD_SUCCEED

CS_INT

CS_TRANS_STATE

The current server transaction state.

Any value. CT_RESULTS must have returned CS_SUCCEED.

CS_INT


Determining whether Browse-mode information is available


Retrieving the command number for current results


Retrieving a message ID


Retrieving the number of compute clauses


Retrieving the number of result data items


Retrieving the number of columns in an order by clause


Retrieving the column IDs of order-by columns


Retrieving the number of rows for the current command


Retrieving the current server transaction state

See also

ct_cmd_props, ct_con_props, ct_results, “Options”, “Server transaction states”