Using the General Global Function in Other UDFs - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
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.