Using GLOP Data in a C/C++ External Routine | Teradata Vantage - Using GLOP Data in a C/C++ External Routine - Teradata Vantage - Analytics Database

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Publication Date
June 2022
Content Type
SQL Reference
Publication ID
B035-1147-172K
ft:locale
en-US
ft:lastEdition
2026-03-06
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
ft:sourceId
dita
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantageā„¢

An external routine that is a member of a GLOP set must first gain access to the GLOP set to use the data in any of the mappings.

To gain access to a GLOP set in a C or C++ external routine, call the FNC_Get_GLOP_Map library function. You must call FNC_Get_GLOP_Map first before calling any other GLOP functions such as FNC_GLOP_Lock, FNC_GLOP_Unlock, FNC_GLOP_Map_Page, or FNC_GLOP_Global_Copy. Call FNC_Get_GLOP_Map first in each phase of a table function that uses any of the other GLOP routines to initialize the memory pointer for that phase.

Here is a code excerpt that uses the FNC_Get_GLOP_Map function. For a complete example of how to use GLOP data in a C external routine, see C Function Using GLOP Data.

#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include <string.h>

struct Company
{
   INTEGER deptid;
   char deptname[30];
};

struct Company_Info
{
   struct Company Dept[20];
}*COMPANY_DETAILS;

void *GLOP_Manager(INTEGER *record_n,
                   INTEGER *result,
                   char sqlstate[6])
{

   int glop_stat;
   GLOP_Map_t *MyGLOP; // Structure GLOP_Map_t is an array of eight
                       // GLOP_ref_t structures, plus some internal
                       // structures. Eight GLOP data references is
                       // the maximum an external routine can map.

   glop_stat = FNC_Get_GLOP_Map(&MyGLOP);

   // Check whether access to the GLOP set is established or not
   if (glop_stat)
   {
      strcpy(sqlstate, "U0001");
      return;
   }

   // Check the first GLOP mapping in the GLOP set
   if (MyGLOP->GLOP[0].GLOP_ptr == NULL)
   {
      strcpy(sqlstate, "U0002");
      return;
   }
   else
   {
      // Use the first GLOP mapping (index 0) here
      COMPANY_DETAILS = MyGLOP->GLOP[0].GLOP_ptr;
      ...
   }

  ...

  return;
}

For details on the FNC_Get_GLOP_Map C library function, see FNC_Get_GLOP_Map.