ct_cancel

Description

Cancel a command or the results of a command.

Syntax

CS_RETCODE ct_cancel(connection, cmd, type)
 
 CS_CONNECTION     *connection;
 CS_COMMAND          *cmd;
 CS_INT                        type;

Parameters

connection

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

For CS_CANCEL_CURRENT cancels, connection must be NULL.

For CS_CANCEL_ATTN and CS_CANCEL_ALL cancels, one of connection or cmd must be NULL. If connection is supplied and cmd is NULL, the cancel operation applies to all commands pending for this connection.

cmd

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

For CS_CANCEL_CURRENT cancels, cmd must be supplied. The cancel operation applies only to the results pending for this command structure.

For CS_CANCEL_ATTN and CS_CANCEL_ALL cancels, if cmd is supplied and connection is NULL, the cancel operation applies only to the command pending for this command structure. If cmd is NULL and connection is supplied, the cancel operation applies to all commands pending for this connection.

type

The type of cancel. The following table lists the symbolic values that are legal for type

Table 3-3: Values for ct_cancel type parameter

Value of type

Result

Notes

CS_CANCEL_ALL

ct_cancel sends an attention to the server, instructing it to cancel the current command.

Client-Library immediately discards all results generated by the command.

Causes this connection’s cursors to enter an undefined state.

To determine the state of a cursor, an application can call ct_cmd_props with property as CS_CUR_STATUS.

CS_CANCEL_ATTN

ct_cancel sends an attention to the server, instructing it to cancel the current command.

The next time the application reads from the server, Client-Library discards all results generated by the canceled command.

Causes this connection’s cursors to enter an undefined state.

To determine the state of a cursor, an application can call ct_cmd_props with property as CS_CUR_STATUS.

CS_CANCEL_CURRENT

ct_cancel discards the current result set.

Safe to use on connections with open cursors.

Returns

ct_cancel returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_PENDING

Asynchronous network I/O is in effect. For more information, see “Asynchronous programming”.

CS_CANCELED

The cancel operation was canceled. Only a CS_CANCEL_CURRENT type of cancel can be canceled.

CS_BUSY

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

CS_TRYING

A cancel operation is already pending for this connection.

Examples

Example 1

          if (query_code == CS_FAIL)
           {
                /*
                ** Terminate results processing and break out of 
                ** the results loop.
                */
                retcode = ct_cancel(NULL, cmd, CS_CANCEL_ALL);
                if (retcode != CS_SUCCEED)
                {
                   ex_error("ex_execute_cmd: ct_cancel() failed");
                }
                break;
           }

This code excerpt is from the exutils.c example program.

Usage


Canceling a command


Canceling current results

See also

ct_fetch, ct_results