Creating UDFs
The same restrictions described in the Teradata Database manuals apply to creating and using UDFs with OLE DB Provider for Teradata.
Compilation Messages
When creating a UDF, several compilation messages are generated by OLE DB Provider for Teradata, however, the method ICommand::Execute returns S_OK. The IErrorRecords interface can be used to view these compilation messages.
Compilation Errors
Errors that occur when compiling a UDF are returned through the IErrorRecords interface. These messages are mixed with the compilation messages. When a compilation error does occur, ICommand::Execute returns an E_FAIL.
UDF Files
The file specified in the DDL used to create a UDF must reside on a Teradata node. If this file is contained on a client machine, the call to the method ICommand::Execute returns an E_FAIL.
Example of User-Defined Functions
The following example shows how to create, rename, and delete a UDF. The source code for the function must exist in the server node. An error occurs if a local file is used.
For this example, the file udf01.c must exist in the /tmp directory on the server teradata1. It's contents are:
void udf01(int i,int* result,char exception[6])
{
*result = i +1;
return ;
}
The DDL statements as described in Chapter 4 of the SQL External Routine Programming manual are executed using ICommand::Execute. Any compilation errors can be retrieved using the IErrorInfo, IErrorRecords, and ISQLErrorInfo interfaces.