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;
This part of the string that follows EXTERNAL NAME … | Specifies … |
---|---|
! | a delimiter. |
C | that the header file is obtained from the client. |
I | that the information between the following two sets of delimiters identifies the name and location of an include file (.h). |
stypes | the name, without the file extension, of the header file. |
udfsrc/stypes.h | the path and name of the header file on the client. |
C | that the source is obtained from the client. |
S | that the information between the following two sets of delimiters identifies the name and location of a C or C++ function source file. |
substr | the name, without the file extension, that the server uses to compile the source. |
udfsrc/substr.c | the path and name of the source file. |
F | that the information after the next delimiter identifies the C or C++ function name. |
udf_substr | the C or C++ function name. |
For more information on installing libraries, see the information about CREATE FUNCTION in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144.