Teradata PT provides an option to create an UDF or an XSP in the database by using the DDL operator.
Teradata PT supports the creation of both client- and server-side UDFs/XSPs
The following apply statement creates a server side UDF named 'yourudf' by using the C file, /root/yourCudf.c residing in the /root directory of the database system:
APPLY ( ' CREATE FUNCTION yourudf( parameter_1 CHAR(1)) RETURNS CHAR LANGUAGE C NO SQL EXTERNAL NAME ''SS!yourudf!/root/yourCudf.c'' PARAMETER STYLE SQL; ' ) TO OPERATOR ( $DDL );
If the C file exists on the client side in the current working directory, this example can be modified to support the client side UDF as follows:
EXTERNAL NAME ''CS!yourudf!yourCudf.c''
This example can also be written as:
EXTERNAL NAME ''CS!yourudf!yourCudf''
In this Case, the Teradata PT first looks for a file named 'yourCudf' in the current directory and if not found, it also looks for the filename with a .c extension 'yourCudf.c'.
The full specification of the syntax, format, and rules for both creating and invoking UDFs and XSPs is beyond the scope of this document. See Teradata Vantage™ - SQL External Routine Programming, B035-1147 for more information on how to create and invoke user-defined functions.