We are experiencing network problems with the site. Some functions may be temporarily unavailable. Please bear with us while we work to resolve these issues.
All Forums Database
Nidhi 6 posts Joined 11/05
08 Jun 2006
UDF

Hello,
Please give me an example. How to write a UDF.
I have the C language function written. I also have the teradata database and the C compiler on the same machine.

What is the default path on the Teradata Server?

CREATE FUNCTION MYDB.func_a (vara INT)
RETURNS INT
CLASS SCALAR
LANGUAGE C
NO SQL
PARAMETER STYLE SQL
EXTERNAL NAME 'CI!stdio.h' 'CI!conio.h' 'CS!helloworld.c' 'F!main';

Is the above syntax correct? How am I supposed to write the path of the header and the source files?

Please look at the EXTERNAL statement particularly

Thanks,
Nidhi

stami27-2406 22 posts Joined 02/06
08 Jun 2006

Hi,
In http://www.teradataforum.com/
is huge amount of Tips and examples.
eg.http://www.teradataforum.com/is_integer.htm

greetings
stami

stami27-2406 22 posts Joined 02/06
08 Jun 2006

Hi,
about the syntax above of the EXTERNAL:
here is a exampel for header file and src file for an
installation on the server:

EXTERNAL NAME 'SI!to_number!/my/home/udf/to_number.h!SS!to_number!/ my/home/udf/to_number.c'

stami

Nidhi 6 posts Joined 11/05
08 Jun 2006

Hello Stami,

Thanks for the reply.

EXTERNAL NAME 'SI!to_number!/my/home/udf/to_number.h!SS!to_number!/ my/home/udf/to_number.c'

Is this a Windows or Unix Server?
I am using a Windows Server currently, but after testing the UDF, I will be creating it on a Unix Teradata Server.


In 'SI!to_number!/my/home/udf/to_number.h!SS!to_number!/ my/home/udf/to_number.c'

What is to_number before the path address?

Thanks,
Nidhi


Nidhi 6 posts Joined 11/05
08 Jun 2006

Is there any setting that I have to enable in Teradata to call the UDFs?

Nidhi

stami27-2406 22 posts Joined 02/06
08 Jun 2006

Hi the above from me was for unix.

In TD the User Rights create alter and exec functions are nessesary.

Here is the description for W2K found in UDF-Orange book:

Full path specified to W2K server source

CREATE FUNCTION udfSubStr(
strexp VARCHAR(512),
n1 INTEGER,
n2 INTEGER
)RETURNS VARCHAR(512)
LANGUAGE C
NO SQL
EXTERNAL NAME 'SS!sname!c:\program files\ncr\tdat\tdconfig\teradata\tdbs_udf\usr\ udf_substr.c!F!udf_substr3'
PARAMETER STYLE SQL;

File is located on the server S and the file type is S source.
The separator character is ! and the name of the server file is sname.
The full path to the file is specified.
The C function name in the file udf_substr3.c is speci-fied
using the function entry option F, udf_substr3.
The specific name defaults to the function name, udfsubstr.

For sname I take the same function name as in the CREATE FUNCTION Clausel

Greetings stami

You must sign in to leave a comment.