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

Teradata Vantageā„¢ - SQL External Routine Programming

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

Consider an external routine that maps one of five XML syntax rules pages depending on the type of document it must process. The XML rules are kept in a read-only system map in the "XML_Document_Syntax" set. The reason for using a system map is that the GLOP is read-only, so only one copy needs to exist and the XML document syntax rules are system wide and all documents need to use the same syntax.

Remember that more than one system type GLOP can be defined in a set. So if there is a need for specific generic system GLOP data, it can be mapped also.

#define XML_INDEX  0
XML_Rules   Current_XML_Rules;
int         Page_map;
int         glop_status

. . .

glop_status = FNC_Get_GLOP_Map(&MyGLOP);
if (!glop_status)
   ... process error: Not a member of any GLOP table
   ... process error: XML Syntax map does not exist

/* Determine page to map, based on "document_type" input parameter */
switch (*document_type)
   case WEB_page:
      Page_map = 1;
   case PDF_page:
      Page_map = 2;
   case Text_page:
      Page_map = 3;
   case Graphic_page:
      Page_map = 4;
   case Formula_page:
      Page_map = 5;
      /* error: invalid documents option - generate an error */

if (MyGLOP->GLOP[XML_INDEX].page != Page_map)
{   if (!FNC_GLOP_Map_Page(XML_INDEX, Page_map)) 
      ... error: could not map page

Current_XML_Rules = MyGLOP->GLOP[XML_INDEX].GLOP_ptr;

/* process the document */