Accessing the Value of a Large Object | Teradata Vantage - Accessing the Value of a Large Object - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantageā„¢
Teradata provides the following library functions for accessing the value of a large object:
  • FNC_LobOpen
  • FNC_LobRead
  • FNC_LobClose
To access the value of a large object, follow these steps:
  1. Call FNC_LobOpen to establish a read context for the large object.

    FNC_LobOpen returns a read context handle for the large object through an output argument of type LOB_CONTEXT_ID. The sqltypes_td.h header file defines LOB_CONTEXT_ID like this:

    typedef long LOB_CONTEXT_ID;

  2. Call FNC_LobRead to read the large object and place the data into a BYTE buffer.

    One of the input arguments to FNC_LobRead is the read context handle that was returned by FNC_LobOpen.

  3. Call FNC_Close to release all resources associated with the read context.

For detailed information on each function, see C Library Functions.

Here is a code excerpt that shows how to access the value of a large object:

#define BUFFER_SIZE 500
   
void do_something ( LOB_LOCATOR *a,
                    LOB_RESULT_LOCATOR *result,
                    char sqlstate[6] )
{
   BYTE            buffer[BUFFER_SIZE];
   FNC_LobLength_t actlen;
   LOB_CONTEXT_ID  id;

   /* Establish a read context for the LOB input argument */
   FNC_LobOpen(*a, &id, 0, BUFFER_SIZE);
   
   /* Read the LOB and place the data into a BYTE buffer */
   FNC_LobRead(id, buffer, BUFFER_SIZE, &actlen);
   
   /* Release the resources associated with the read context */
   FNC_LobClose(id);
   
    ...
  
}

For a complete example, see C Scalar Function Using LOBs.