Using the General Global Function in Other UDFs - 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™

Other UDFs in the same database that use the global1 code declare the general global function as external:

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

The corresponding CREATE FUNCTION statement only has to specify the source for the UDF:

CREATE FUNCTION UDF1(B VARCHAR(20000) CHARACTER SET LATIN)
RETURNS INTEGER
  ...
EXTERNAL NAME 'CS!udf2!udf2.c';

The code for the general global function had to be provided only once, and can be shared by all other UDFs in the same library that provide the external statement.