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
Language
English (United States)
Last Update
2023-07-11
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
B035-1147
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 only had to be provided once and can be shared by all other UDFs in the same library as long as they provide the external statement.