A regular row result set is generated by the execution of a Transact-SQL select statement on a server.
A regular row result set contains zero or more rows of tabular data.
An application typically calls the following routines to process a regular row result set:
ct_res_info, which returns information about the current result set. Most often, an application uses ct_res_info to get the number of columns in the current result set. However, ct_res_info also returns other types of information—for example, the number of rows affected by the current command.
ct_describe, which returns information about a particular result item in the current result set. An application generally needs to call ct_describe once for each result item before binding each result item to a program variable.
ct_bind, which binds a result item to a program variable. Binding creates an association between a result item and a data space.
ct_fetch, which copies result data into bound variables.
Binding is the process of associating a result item with program data space. Fetching is the process of retrieving a data instance of a result item. If binding has been specified for a result item, then fetching causes a data instance of the item to be copied into the program data space.
Most synchronous applications use a program structure similar to the following one to process a regular row result set:
case CS_ROW_RESULT
ct_res_info(CS_NUMDATA) to get the number of columns
for each column:
ct_describe to get a description of the column
ct_bind to bind the column to a program variable
end for
while ct_fetch returns CS_SUCCEED or CS_ROW_FAIL
if CS_SUCCEED
process the row
else if CS_ROW_FAIL
handle the row failure
end if
end while
switch on ct_fetch’s final return code
case CS_END_DATA...
case CS_CANCELED...
case CS_FAIL...
end switch
end case