17.10 - Example Using FNC_GetQueryBandPairs - 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>
#include<string.h>

void getPairs ( int *NumPairs, char sqlstate[6] )
{

   FNC_QB_Pair_t *pairPtr;
   char          *QBandBuf;
   int            QBLen;

   QBandBuf = FNC_malloc(FNC_MAXQUERYBANDSIZE);
   if (QBandBuf == NULL)
   {
      strcpy(sqlstate, "U0004");
      strcpy((char *) error_message, "malloc failed");
   }
   else
   {
      FNC_GetQueryBand(QBandBuf, FNC_MAXQUERYBANDSIZE, &QBLen);
      if (QBLen > 0)
      {
         pairPtr = FNC_GetQueryBandPairs(QBandBuf, QB_FIRST, NumPairs); 
         if (*NumPairs > 0)
            FNC_free(pairPtr);
      }
      strcpy(sqlstate, "00000");
   }
   FNC_free(QBandBuf);
   return;
}