Processing regular row results

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:

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