![]() | ![]() |
Home |
|
|
Open Client Client-Library/C Reference Manual |
|
| Chapter 2 Topics |
|
| Commands |
|
| Sending commands |
All commands are defined and sent in three steps:
Initiate the command. This identifies the command type and what it executes.
Define parameter values, if necessary.
Send the command. ct_send writes the command symbols and data to the network. The server then reads the command, interprets it, and executes it.
An application sends several types of commands to a server:
An application calls ct_command to initiate a language, message, package, remote procedure call (RPC), or send-data command.
An application calls ct_cursor to initiate a cursor command.
An application calls ct_dynamic to initiate a dynamic SQL command.
The following types of commands take parameters:
A language command, when the command text contains variables
An RPC command, when the stored procedure takes parameters
A cursor declare command, when the body of the cursor contains host variables or when some of the cursor's columns are for update
A cursor open command, when the body of the cursor contains host language parameters
A cursor update command if the text of the update statement contains variables
A message command
A dynamic SQL execute command
An application calls ct_param or ct_setparam once for each parameter a command requires. These routines perform the same function, except that ct_param copies a parameter value, while ct_setparam copies the address of a variable that contains the value. If ct_setparam is used, Client-Library reads the parameter value when the command is sent. This allows the application to change the parameter values that were specified with ct_setparam before resending the command.
Sending a commandAfter a command has been initiated and its parameters have been defined, an application calls ct_send to send the command to the server. The server then interprets the command, executes it, and returns the results to the client application.
Resending a commandFor most command types, Client-Library allows an application to resend the command after the results of previous execution have been processed. Enhancements to ct_send, ct_cursor, and ct_bind, and the addition of ct_setparam routine in version 11.1 allow batch-processing applications to resend commands and reuse binds when repeatedly executing the same server command. This feature can eliminate redundant calls to ct_bind, ct_command, ct_cursor, and ct_param.
The application resends commands as follows:
If necessary, the application changes values in parameter source variables.
If the command requires parameters, the application should define parameter source variables with ct_setparam instead of passing values with ct_param. Input parameter values passed with ct_param can not be changed when a command is resent.
The application calls ct_send to resend the command after the results of the previous command execution have been processed and before a new command is initiated on the command structure.
An application can resend all types of commands except:
Send-data commands initiated by ct_command(CS_SEND_DATA_CMD)
Send-bulk commands initiated by ct_command(CS_SEND_BULK_CMD)
ct_cursor cursor commands other than cursor-update or cursor-delete
ct_dynamic commands other than execute-immediate commands or a command to execute a prepared statement
|
|