ct_get_data versus dbdata

Client-Library offers no direct equivalents for DB-Library’s dbdata or for the similar routines dbadata, dbretdata, and dbretstatus. All of these routines return a pointer to a buffer that contains a data value.

Client-Library does allow applications to retrieve data values with ct_get_data as an alternative to binding. Applications typically use ct_get_data to retrieve large text or image columns, but it can be used on data of any type.

ct_get_data copies all or part of a data value into a caller-supplied buffer. A call to ct_get_data can replace a call to dbdata, dbadata, dbretdata, or dbretstatus. However, ct_get_data has the following restrictions:

The following code fragment illustrates a ct_get_data call that retrieves a CS_INT data item:

CS_INT status;
... after ct_fetch() has returned CS_SUCCEED ...
ret = ct_get_data(cmd, 1, (CS_VOID *)status,
                 CS_SIZEOF(CS_INT), (CS_INT *) NULL);
if (ret != CS_END_ITEM && ret != CS_END_DATA)
{
   printf("Error: ct_get_data failed.\n");
}
else
{
   printf(“Status is %ld.\n”, (long) status);
}

As with dbdata, data retrieved with ct_get_data must be converted if the value is not already expressed in the desired datatype. A Client-Library application can call the CS-Library routine cs_convert to convert data.