16.20 - Using GLOP Data in a C/C++ External Routine - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
April 2020
Content Type
Programming Reference
Publication ID
English (United States)

An external routine that is a member of a GLOP set must first gain access to the GLOP set before it can 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. Also, you should 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];

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)

   // Check the first GLOP mapping in the GLOP set
   if (MyGLOP->GLOP[0].GLOP_ptr == NULL)
      // Use the first GLOP mapping (index 0) here



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