Client-Library changes

The CS_LOCATOR datatype supports LOB locator. The cs_locator_alloc() and cs_locator_drop() APIs allocate and deallocate memory for CS_LOCATOR variables. cs_locator() has been added to retrieve information from a CS_LOCATOR variable.

Client-Library routines cs_convert() and ct_bind() have been enhanced to handle CS_LOCATOR variables.


CS_LOCATOR

CS_LOCATOR is an opaque datatype that stores locator values and optional prefetched data. Use cs_locator_alloc() to allocate memory for a CS_LOCATOR variable before binding the incoming locator to the variable, otherwise, an error occurs. When the variable is no longer needed, use cs_locator_drop() to free its memory.

CS_LOCATOR variables can be reused, however, the current locator value in Adaptive Server is valid only until the transaction ends.

The type constants for CS_LOCATOR are:

Use cs_convert() to retrieve the locator’s prefetched data and the character representation of the locator value from the CS_LOCATOR variable. Converting CS_LOCATOR to a CS_CHAR returns the locator’s hexadecimal value as a string. Converting the locator to CS_TEXT_TYPE, CS_IMAGE_TYPE, or CS_UNITEXT_TYPE returns the locator’s prefetched data.

Table 8: Supported LOB locator conversions

CS_TEXT_ LOCATOR

CS_IMAGE_ LOCATOR

CS_UNITEXT_ LOCATOR

LEGEND: X = supported conversion.

CS_CHAR_TYPE

X

X

X

CS_TEXT_TYPE

X

CS_IMAGE_TYPE

X

CS_UNITEXT_TYPE

X

CS_TEXT_LOCATOR

X

CS_IMAGE_LOCATOR

X

CS_UNITEXT_LOCATOR

X

When working with locator datatypes:


cs_locator()

Retrieves information from a CS_LOCATOR variable, such as prefetched data, the total length of the LOB in the server, or the character representation of the locator pointer.

Syntax

CS_RETCODE cs_locator(ctx, action, locator, type, buffer, buflen,
   outlen)

CS_CONTEXT        *ctx;
CS_INT                    action;
CS_LOCATOR        *locator;
CS_INT                    type;
CS_VOID                *buffer;
CS_INT                   buflen;
CS_INT                     *outlen;

Parameters

Returns

Return Value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_TRUNCATED

The result has been truncated because the buffer is too small.

CS_FAIL

The routine failed.


cs_locator_alloc()

Allocates a CS_LOCATOR datatype structure.

Syntax

CS_RETCODE cs_locator_alloc(ctx, locator)

CS_CONTEXT *ctx;
CS_LOCATOR **locator;

Parameters

Returns

Return Value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.


cs_locator_drop()

Deallocates a CS_LOCATOR datatype structure.

Syntax

CS_RETCODE cs_locator_drop(ctx, locator)

CS_CONTEXT *ctx;
CS_LOCATOR *locator;

Parameters

Returns

Return Value

Meaning

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.


isql enhancement

isql displays the LOB locator value in its hexadecimal character form. Prefetched data stored in CS_LOCATOR does not appear.

Example Converts LOB data to locators, and displays the locator value:

1> set send_locator on
2> go

1> select * from testable
2> go
charcol         textcol
--------------- --------------------------------------------------
Hello           0x48656c6c6f20576f726c642e2048657265204920616d2e2e