Specifying User-Supplied Include Files - 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™

If a UDF includes a user-supplied header file, the EXTERNAL clause in the CREATE FUNCTION statement must specify the name and path of the header file.

Consider the following function that includes the header file stypes.h:

/*****  C source file name: substr.c  *****/
   
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include "stypes.h"
   
void udf_substr( VARCHAR_LATIN *inputString,
                 INTEGER       *start,
                 VARCHAR_LATIN *result,
                 char          sqlstate[6])
{
     ...
}

Here is an example of CREATE FUNCTION that specifies the name and path of the user-supplied header file:

CREATE FUNCTION udfSubStr
  (inputString VARCHAR(512),
   start       INTEGER)
RETURNS VARCHAR(512)
LANGUAGE C
NO SQL
EXTERNAL NAME 'CI!stypes!udfsrc/stypes.h!CS!substr!udfsrc/substr.c!F!udf_substr'
PARAMETER STYLE TD_GENERAL;
String Part after EXTERNAL NAME Meaning
! Delimiter.
C Header file is obtained from client.
I Information between following two sets of delimiters identifies name and location of include file (.h).
stypes Name of header file, without file extension.
udfsrc/stypes.h Path and name of header file on client.
C Source is obtained from client.
S Information between following two sets of delimiters identifies name and location of C or C++ function source file.
substr Name server uses to compile source, without file extension.
udfsrc/substr.c Path and name of source file.
F Information after next delimiter identifies C or C++ function name.
udf_substr C or C++ function name.

See CREATE FUNCTION in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144.