16.20 - C Function Definition That Generates GLOP Data - 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)

This function generates GLOP data that is added to a GLOP set as a system type GLOP.

/********** File: compinform.c **********/

#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include <string.h>
#include <stdlib.h>
#define IsNull -1
#define IsNotNull 0
#define loopsize  20

/* Generate data for different departments in a retail store. */

struct Company
   INTEGER deptid;
   char deptname[30];

struct Company_INFO
   struct Company Dept[loopsize];

void compinform( LOB_RESULT_LOCATOR *cmp_info,
                 INTEGER *cmp_infoISNULL,
                 char sqlstate[6],
                 SQL_TEXT extname[129],
                 SQL_TEXT specific_name[129],
                 SQL_TEXT error_message[257] )

   FNC_LobLength_t actlen;
   int i;
   const char truncate1a[6] = "22001";
   char *Dept_Name[20] =
      {"Automotive", "Hardware", "Bed", "Bath", "Toys", "Food",
       "Electronics", "Games", "Photo", "Kitchen", "Seasonal", "Books",
       "Furniture", "Pharmacy", "Men", "Women", "Baby", "Kids",
       "Shoes", "Nursery"};

   // Allocate memory to store the contents.

      (struct Company_INFO *)FNC_malloc(sizeof(struct Company_INFO));

   // Store data in a structure format.

   for (i=0; i<loopsize; i++)

   // Add data to BLOB.

   if (FNC_LobAppend(*cmp_info,COMPANY_DETAILS,
                     sizeof(*COMPANY_DETAILS),& actlen) !=0)
      strcpy(sqlstate, truncate1a);

   // Free the memory that was allocated to the structure CompanyName.