ct_results returns with result_type of CS_DESCRIBE_RESULT to indicate that the input parameter formats are available. Applications can retrieve the parameter formats in one of two ways:
With ct_res_info and ct_describe
The application calls ct_res_info to determine the number of parameters; then, for each parameter, it calls ct_describe to initialize a CS_DATAFMT structure with a description of the parameter.
Typically, an application using this method keeps the CS_DATAFMT structures in an array or list for use with later calls to ct_param or ct_setparam.
With ct_dyndesc or ct_dynsqlda
Both these routines allow the application to retrieve formats into a structure that can later be used to pass parameters for the command that executes the statement. Both of these routines:
Retrieve a description of the input parameters required to execute a prepared dynamic SQL statement
Define input parameter values for the execution of a prepared statement
Retrieve a description of the data results that will be returned when a prepared statement is executed
Retrieve data values in the result set returned by the execution of a prepared statement
The differences between the routines are:
ct_dynsqlda – retrieves formats into a SQLDA structure. The application must allocate the memory for this structure before retrieving formats into it. ct_dynsqlda requires only a single call to perform each operation.
ct_dyndesc – retrieves formats into an internal Client-Library data structure that is hidden from the application. ct_dyndesc requires several calls to perform a single operation.
ct_dyndesc and ct_dynsqlda both call ct_res_info and ct_describe internally. When used to pass parameter values, ct_dyndesc and ct_dynsqlda both call ct_param internally.