Passing LOB Data in the Intermediate Aggregate Storage Area - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

A locator is valid only during the execution of the UDF to which it is passed as an argument. Because of this limitation, a locator cannot be passed in the intermediate aggregate storage area that aggregate functions use to accumulate summary information.

Instead, an aggregate function must convert a locator to a persistent object reference, a reference that is valid over the execution of the SQL request.

The sqltypes_td.h header file defines a persistent object reference as a LOB_REF type:

typedef struct LOB_REF{
    unsigned char data[50];
} LOB_REF;

A LOB_REF is not valid outside of the request in which it is created. If you attempt to pass a LOB_REF out of the request, perhaps by storing it in a table, and later attempt to convert it back to a locator, the function will fail.

To convert a locator to or from a persistent object reference that can be passed in the intermediate aggregate storage area, Teradata provides the following library functions:
  • FNC_LobLoc2Ref
  • FNC_LobRef2Loc
FOR … SEE …
detailed information on FNC_LobLoc2Ref and FNC_LobRef2Loc, including examples of how to use the functions C Library Functions
a complete example of an aggregate function using LOBs C Aggregate Function Using LOBs