Creating New User Defined Functions

Connectivity
Fan

Creating New User Defined Functions

How to create our own user defined functions please let me know its very important
2 REPLIES
Enthusiast

Re: Creating New User Defined Functions

If, instead of clicking on 'Discussion forums', you move down a bit and right a bit on the Teradata.Com page, you'll see a link to 'Drivers and UDFs'.

You can pinch a pre-written UDF from there and tailor it to your own needs :-) The one you want to write is probably already there.
Enthusiast

Re: Creating New User Defined Functions

1:create a file name it 'helloworld.c',locate it in c:\temp
2:open file helloworld.c ,and copy the follow words:

#define SQL_TEXT Latin_Text
#include "sqltypes_td.h"
void Sayhello(VARCHAR_LATIN *result){
strcpy((char*)result,(const char*)"Hello World!");
return;
}

3:save and close file helloworld.c
4:create a file name it 'helloworld.bteq',locate it in c:\temp
5:open file helloword.bteq ,and copy the follow words:

.logon yourdbc/dbc,dbc;
database yourDB;
replace function Sayhello()
RETURNS VARCHAR(13)
LANGUAGE C
NO SQL
EXTERNAL NAME
'CS!helloworld!c:\temp\helloworld.c!F!Sayhello'
PARAMETER STYLE TD_GENERAL;
.logoff

6:save and close file helloworld.bteq
7:start a command window,cd c:\temp path,and run : bteq \< helloworld.bteq
8:open Teradata SQL Assistant ,and type
SELECT yourDB.Sayhello();
run it!

That's all,if you want to konw more information ,please open PDF help document and read it.