Most synchronous Client-Library programs process results using a loop controlled by ct_results. Inside the loop, a switch takes place on the type of result that is currently available for processing, as indicated by the value of ct_results’ parameter result_type. Different types of results require different types of processing.
result_type is also used to indicate the outcome of a server command that returns no results, for example, an insert or delete command.
Most synchronous applications use a program structure similar to the following one to process results:
while ct_results returns CS_SUCCEED
(optional) ct_res_info to get current
command number
switch on result_type
/*
** Values of result_type that indicate
** fetchable results:
*/
case CS_COMPUTE_RESULT...
case CS_CURSOR_RESULT...
case CS_PARAM_RESULT...
case CS_ROW_RESULT...
case CS_STATUS_RESULT...
/*
** Values of result_type that indicate
** non-fetchable results:
*/
case CS_COMPUTEFMT_RESULT...
case CS_MSG_RESULT...
case CS_ROWFMT_RESULT...
case CS_DESCRIBE_RESULT...
/*
** Other values of result_type:
*/
case CS_CMD_DONE...
(optional) ct_res_info to get the
number of rows affected by
the current command
case CS_CMD_FAIL...
case CS_CMD_SUCCEED...
end switch
end while
switch on ct_results’ final return code
case CS_END_RESULTS...
case CS_CANCELED...
case CS_FAIL...
end switch