Sending the new column value

Once it has the current I/O descriptor for a column value, the application performs the update:

  1. Call ct_command to initiate a send-data command.

  2. Modify the I/O descriptor, if necessary. Most applications change only the values of the locale, total_txtlen, or log_on_update fields.

  3. Call ct_get_data to set the I/O descriptor for the column value. The textptr field of the I/O descriptor structure identifies the target column of the send-data operation.

  4. Call ct_send_data in a loop to write the entire text or image value. Each call to ct_send_data writes a portion of the text or image value.

  5. Call ct_send to send the command.

  6. Call ct_results to process the results of the command. An update of a text or image column generates a a parameter result set containing a single parameter, the new text timestamp for the value. If the application plans to update this column value again, it must save the new timestamp and copy it into the CS_IODESC for the column value before calling ct_data_info (step 3, above) to set the I/O descriptor for the new update.

Most applications use a program structure similar to the following to update text or image columns:

ct_con_alloc to allocate connection1 and connection2
 ct_cmd_alloc to allocate cmd1 and cmd2
 
 ct_command(cmd1) to select columns 
     (including text) from table
 ct_send to send the command
 while ct_results returns CS_SUCCEED
     (optional) ct_res_info to get description of result set
     (optional) ct_describe to get descriptons of columns
     (optional) ct_bind if binding any columns
 
     while ct_fetch(cmd1) returns rows
         for each text column
             /* Retrieve the current CS_IODESC for the column */
             if you want the column’s data, loop on ct_get_data
                     while there’s data to retrieve
             if you don’t want the column’s data, call 
                     ct_get_data once with buflen of 0 to 
                     refresh the CS_IODESC
             ct_data_info(cmd1, CS_GET) to get the CS_IODESC
             
             /* Update the column */
             ct_command(cmd2) to initiate a send-data command
             if necessary, modify fields in the CS_IODESC
             ct_data_info(cmd2, CS_SET) to set the CS_IODESC for
                     the column
             while there is data to send
                 ct_send_data(cmd2) to send a chunk of data
             end while
             ct_send(cmd2) to send the send-data command
             ct_results(cmd2) to process the send-data results
         end for
     end while
 end while