Example Using FNC_LobOpen_CL - 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
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
lifecycle
latest
Product Category
Teradata Vantage™

The following code reads a LOB from the input stream and copies its content into the output stream.

LOB_RESULT_LOCATOR   lrl_a;
int                  streamno=0;
int                  i;
BYTE                 *locator;
int                  locatorLength;
int                  null_ind;
FNC_LobLength_t      lobLength;
LOB_CONTEXT_ID       lobid;
BYTE                 Buffer[BufferSize];
int                  length;
int                  truncerr;
FNC_TblOpHandle_t    *Handle, *OutHandle;
.......

   // Get locator for LOB in column  i  of output stream  streamno 
   lrl_a = FNC_LobCol2Loc(streamno, i);
   // Get client locator for input LOB
   FNC_TblOpGetAttributeByNdx(Handle, i, (void **) &locator, &null_ind, &locatorLength);
   if (null_ind != -1) {
      // Open input LOB
      FNC_LobOpen_CL(locator, &lobid, 0, 0);
      truncerr = 0;
      // Read input LOB and append it to output LOB
      while( FNC_LobRead(lobid, Buffer, BufferSize, &length) == 0 && !truncerr)
         truncerr=FNC_LobAppend (lrl_a, Buffer, length, &actlen);
         // Close input LOB
      FNC_LobClose(lobid);
   }
   else
      // Set output column to NULL
      FNC_TblOpBindAttributeByNdx(OutHandle, i, locator, null_ind, locatorLength);