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

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

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];
}*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.