ct_data_info

Description

Define or retrieve a data I/O descriptor structure.

Syntax

CS_RETCODE ct_data_info(cmd, action, colnum, iodesc)
 
 CS_COMMAND    *cmd;
 CS_INT                 action;
 CS_INT                 colnum;
 CS_IODESC          *iodesc;

Parameters

cmd

A pointer to the CS_COMMAND structure managing a client/server operation.

action

One of the following symbolic values:

Value

Meaning

CS_SET

Define an I/O descriptor

CS_GET

Retrieve an I/O descriptor

colnum

The number of the text or image column whose I/O descriptor is being retrieved.

If action is CS_SET, pass colnum as CS_UNUSED.

If action is CS_GET, colnum refers to the select-list ID of the text or image column. The first column is column number 1, the second is number 2, and so forth. An application must select a text or image column before it can update the column.

colnum must represent a text or image column.

iodesc

A pointer to a CS_IODESC structure. A CS_IODESC structure contains information describing text or image data. For more information about this structure, see “CS_IODESC structure”.

Returns

ct_data_info returns the following values:

Return value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

CS_BUSY

An asynchronous operation is already pending for this connection. See “Asynchronous programming”.

Examples

Example 1

        /*
         ** FetchResults()
         **
         ** The result set contains four columns: integer, text, 
         ** float, and integer.
         */
        CS_STATIC CS_RETCODE
         FetchResults(cmd, textdata)
         CS_COMMAND            *cmd;
         TEXT_DATA            *textdata;
         {
         CS_RETCOD    retcode;
             CS_DATAFMT   fmt;
             CS_INT       firstcol;
             CS_TEXT      *txtptr;
             CS_FLOAT     floatitem;
             CS_INT       count;
             CS_INT       len;
            /* 
             ** Before we call ct_get_data(), we can only bind
             ** columns that come before the column on which we 
             ** perform the ct_get_data().
             ** To demonstrate this, bind the first column
             ** returned.
             */
             ...CODE DELETED.....
            /* Retrieve and display the result */
             while(((retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED,
                 CS_UNUSED,&count)) == CS_SUCCEED) || 
                 (retcode == CS_ROW_FAIL) )
             {
                 /* Check for a recoverable error */
                 ...CODE DELETED.....
                /* Get the text data item in the 2nd column */
                 ...CODE DELETED.....
             /* 
              ** Retrieve the descriptor of the text data. It
              ** is available while retrieving results of a select 
              ** query. The information will be needed for later 
              ** updates.
              */
                 retcode = ct_data_info(cmd, CS_GET,  2, 
                     &textdata->iodesc);
                 if (retcode != CS_SUCCEED)
                 {
                     ex_error("FetchResults: cs_data_info()
                         failed");
                     return retcode;
                 }
                /* Get the float data item in the 3rd column */
                 ...CODE DELETED.....
                /* Last column not retrieved */
             }
            /*
             ** We're done processing rows. Check the final return 
             ** value of ct_fetch().
             */
             ...CODE DELETED.....
            return retcode;
         }

This code excerpt is from the getsend.c sample program.

Usage

See also

ct_get_data, ct_send_data, “text and image data handling”