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

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1147-171K
Language
English (United States)

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.