All Forums Connectivity
srikant9099 2 posts Joined 05/08
16 May 2008
Create UDF

Hi All,Can anybody tell me, How to create and execute the UDF with simple example.RegardsSrikant

Adeel Chaudhry 773 posts Joined 04/08
21 May 2008

Hello,Following is the sample UDF code file, save it as "udfvarchartest.c":#define SQL_TEXT Latin_Text#include "sqltypes_td.h"void udfvarchartest( VARCHAR_LATIN *var_in_varchar1, VARCHAR_LATIN *var_out_varchar1){ strcpy(var_out_varchar1, var_in_varchar1); return;}Following is the code for its compilation save it as "udfvarchartest.btq":.LOGON username/pass;DATABASE db;REPLACE FUNCTION udfvarchartest (var1 VARCHAR(20)) RETURNS VARCHAR(20) LANGUAGE C NO SQL EXTERNAL NAME 'CS!udfvarchartest!udfvarchartest.c!F!udfvarchartest' PARAMETER STYLE TD_GENERAL;.LOGOFF;Place both the files in one folder e.g. c:\UDF and run bteq < udfvarchartest.btqHTH!Regards,Adeel

-- If you are stuck at something .... consider it an opportunity to think anew.

StevenHanes 5 posts Joined 07/10
14 Sep 2010

I used this template today and it worked perfectly, thanks.

chuljay 1 post Joined 08/12
15 Aug 2012

Can some one provide me steps for creating a simple Java UDF function (without any SQL), and then use that function as a UDF in an update query?

For example, I want to write a Java function which reverses the Last name column in a Teradata table and then update the reversed value back to the table column.  For example if my java function is called 'reverse()', once it's compiled and stored in Teradata, I should be able to run a query as follows.

Update Employee set Lname = reverse(Lname) where dept = 'Marketing';

 

You must sign in to leave a comment.