Creating General Global Functions | SQL External Routine Programming | Vantage - Creating General Global Functions - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantageā„¢

One way to create a general global function is to supply the code in a C/C++ function for the first UDF you create.

For example, suppose you have the following general global function:

/*****  Source code filename: global1.c  *****/
int global1( char *text1)
{
   ...
}

The C code for the first UDF declares the general global function as external, and looks like this:

/*****  Source code filename: udf1.c  *****/
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
 
external global1(char *text1);
   
void udf1(CHARACTER *a, INTEGER *result,
          ... )
{
   int global_result;
 
   global_result = global1(a);
   ... 
   
}

The corresponding CREATE FUNCTION statement must specify the source for the general global function and the first UDF:

CREATE FUNCTION UDF1(A CHAR(30) CHARACTER SET LATIN)
RETURNS INTEGER
  ...
EXTERNAL NAME 'CS!global1!global1.c!CS!udf1!udf1.c';