All Forums Connectivity
vshar 5 posts Joined 01/09
16 Apr 2009
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_1ASSELECT tab1.col1, tab2.col2, tab1.col3, calc_func(tab1.col2, tab1.col3, tab1.col4)FROM tab1INNER JOIN tab2ON 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

Adeel Chaudhry 773 posts Joined 04/08
18 May 2009

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

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

Venkatesh G 17 posts Joined 05/09
18 May 2009

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

You must sign in to leave a comment.