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:
ct_get_data requires that the application pre-allocate a buffer for the data.
An application can only use ct_get_data on result items past the last item that was bound with ct_bind. For example, if result item numbers 1, 3, and 4 are bound, then it is an error to call ct_get_data for item numbers 1 through 4.
With dbretdata and dbretstatus, the application did not have to fetch parameter values or return status values. With Client-Library, ct_fetch must be called before return parameter values or return status values can be retrieved with ct_get_data.
For each call to ct_fetch that returns CS_SUCCEED, the application can only retrieve a data item with ct_get_data once.
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.