Database
Enthusiast

Compiling UDF with Object File

While compiling UDF in Teradata, We place the .c program of the function in a folder and compile the function structure in Teradata specifying the file path in the EXTERNAL NAME part.

How do we compile an UDF if we are given the object file (.o extn) of the function only?

Thanks

Tags (2)
4 REPLIES

Re: Compiling UDF with Object File

I am not sure if you can do that. It appears you do have .c file, then why do you require to compile using an object file?

Re: Compiling UDF with Object File

In the CREATE (or REPLACE) FUNCTION statement, there is an option EXTERNAL NAME. To compile a UDF with a given object file, specify this option with the suboption CO in the string. As an example, let us assume the following:

Your objective file is called "myudf.o".

The function to use in the source code is called "myudffun(...)"

Then specify:

CREATE FUNCTION ...

...

EXTERNAL NAME 'CO!myudf!<full_path_to_object_file>/myudf.o!F!myudffun!D!'

...

In general, you want to compile with the last D suboption when testing, because it enables the debugger.

As a reminder, if you worked with the source file "myudf.c" instead of the object file, then the above suboption would be correspondingly expressed as:

EXTERNAL NAME 'CS!myudf!<full_path_to_object_file>/myudf.c!F!myudffun!D!'

Hope this helps,

Alexander.