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

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
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';