All Forums Database
mani.atkuri 4 posts Joined 02/12
27 Jan 2013
Can we access a table from SQL UDF in TD 14?

Hello,
We are trying to create a SQL Udf .It should access the table. For example, like below
CREATE FUNCTION SYSLIB.INCLUDE (RLS CHAR(1))
RETURNS VARCHAR(90)
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
COLLATION INVOKER
INLINE TYPE 1
RETURN
 SELECT SECUR_LBL FROM  db.SECUR_LABEL_USER WHERE USER_ID=USER ANd SECUR_TYPE=RLS ;
Is this possible with Td 14 version? Any help would be really helpful.
Thank you.

Adeel Chaudhry 773 posts Joined 04/08
30 Jan 2013

Are you converting fuctions from other RDBM (e.g SQL Server) to Teradata?
What will be the use of this fuction?
 
Regards, Adeel

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

ToddAWalter 316 posts Joined 10/11
30 Jan 2013

A SQL UDF is only allowed to perform an expression and return the result. A Select is not allowed in a SQL UDF.

jilseman 1 post Joined 08/11
01 Feb 2013

accessing objects from within functions has been a useful feature in other DBMS (eg SQL Server)
you are able to build a reusable set of functions for lookups, data validations, etc that can be use in other SPs, querys, etc allowing the developers to join to functions as virtual tables, select only certain values from the output, etc.
 
While Teradata is superior is many areas, it seems they are about 5-6 years behind other DBMSs when is comes to being developer friendly.
Are there plans to add this capabilty?

dheld2 1 post Joined 12/11
03 Feb 2013

So if that is the case, (

A SQL UDF is only allowed to perform an expression and return the result. A Select is not allowed in a SQL UDF.

)
 
THen what is the correct way to impliment what Mani has asked?  Can you select and return data in a c or Java Function UDF?

Adeel Chaudhry 773 posts Joined 04/08
18 Mar 2013

For the correct way o implement that .... again .... What will be the use of this fuction?

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

You must sign in to leave a comment.