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

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
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;
GLOP_Map_t *MyGLOP;
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
if ( MyGLOP->GLOP[XML_INDEX].GLOP_Ptr == NULL)
{
   ... 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;
      break;
   case PDF_page:
      Page_map = 2;
      break;
   case Text_page:
      Page_map = 3;
      break;
   case Graphic_page:
      Page_map = 4;
      break;
   case Formula_page:
      Page_map = 5;
      break;
   Default:
      /* 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 */