17.10 - Example Using FNC_LobAppend - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#define BUFFER_SIZE 100000

void concat2( LOB_LOCATOR *a,
              LOB_LOCATOR *b,
              LOB_RESULT_LOCATOR *result,
              char sqlstate[6] )
{
   FNC_LobLength_t actlen;
   BYTE            buffer[BUFFER_SIZE];
   LOB_CONTEXT_ID  id;
   int             trunc_err = 0;

   /* Append the first argument. */

   FNC_LobOpen(*a, &id, 0, 0);

   while( FNC_LobRead(id, buffer, BUFFER_SIZE, &actlen) == 0
          && !trunc_err )
  trunc_err = FNC_LobAppend(*result, buffer, actlen, &actlen); 

   FNC_LobClose(id);

   ...

}