How to use cursors in UDF

Connectivity
N/A

How to use cursors in UDF

We are converting MS -SQL code to Teradata. In my SQL code we have a view which calls a function to calculate the column value. This function uses a cursor on one of the tables.

CREATE VIEW vw_1
AS

SELECT
tab1.col1,
tab2.col2,
tab1.col3,
calc_func(tab1.col2, tab1.col3, tab1.col4)
FROM
tab1
INNER JOIN tab2
ON tab1.col1 = tab2.col1;

Function calc_func calls a cursor on tab3 and calculates the return value based on input parameters.


Can I call cursor in a UDF. I could not find it anywhere on the web or is there any other options like( calling stored procedure from the function)

Thanks

2 REPLIES
Teradata Employee

Re: How to use cursors in UDF

Hello,

No, you cannot use cursors in Teradata UDFs, infact Teradata UDFs are coded in C/C++, not in SQL like MS SQL Server.

What you can do is to re-write the query with sub-query and get the desired results.

HTH!

Regards,

Adeel

Re: How to use cursors in UDF

I delected the question and created new question, could you please answer my question?