MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is it possible to open a Cursor inside a Scalar UDF?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
jayi
Beginner


Joined: 13 Jun 2005
Posts: 4
Topics: 2
Location: Chicago

PostPosted: Tue Jun 28, 2005 12:45 am    Post subject: Is it possible to open a Cursor inside a Scalar UDF? Reply with quote

Is it possible to open a Cursor inside a Scalar UDF?Attempts to do the same are giving errors.However the same code when compiled as a procedure(with the return variable replaced with an OUT parameter) is compiling fine.Please help!
Back to top
View user's profile Send private message
Joy
Beginner


Joined: 09 May 2005
Posts: 7
Topics: 6
Location: Kolkata

PostPosted: Tue Jun 28, 2005 1:46 am    Post subject: Reply with quote

Hi Jayi,
Even I'm trying to do the same thing but its not working.The IBM DB2 Red Book contains code that has a cursor declaration within a UDF.But its not working for me
Back to top
View user's profile Send private message Send e-mail
rublu
Beginner


Joined: 14 Jun 2005
Posts: 5
Topics: 2

PostPosted: Tue Jun 28, 2005 10:00 pm    Post subject: Reply with quote

Could you give the error messages you are getting. Actually it is possible to open the cursor inside an UDF (procedures).
_________________
------------
Ruben
Back to top
View user's profile Send private message
jayi
Beginner


Joined: 13 Jun 2005
Posts: 4
Topics: 2
Location: Chicago

PostPosted: Wed Jun 29, 2005 12:32 am    Post subject: Reply with quote

Hi Rublu,

Here's the error code:DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "FOR" was found following " DECLARE C1
CURSOR". Expected tokens may include:
"<SQL_variable_condition_declaration>". LINE NUMBER=27. SQLSTATE=42601
sqlcode : -104
Back to top
View user's profile Send private message
rublu
Beginner


Joined: 14 Jun 2005
Posts: 5
Topics: 2

PostPosted: Wed Jun 29, 2005 2:54 am    Post subject: Reply with quote

Jayi,

I misunderstood the context earlier. Scalar UDFs will not return any resultsets. Refer http://publib.boulder.ibm.com/infocenter/db2help/index.jsp?topic=/com.ibm.db2.udb.doc/ad/c0009701.htm for more details.
_________________
------------
Ruben
Back to top
View user's profile Send private message
jayi
Beginner


Joined: 13 Jun 2005
Posts: 4
Topics: 2
Location: Chicago

PostPosted: Wed Jun 29, 2005 9:10 am    Post subject: Reply with quote

Rublu,
My intention was not to return a result set.I was trying to perform an operation on each row of a table and form a concatenated string containing the values of only those rows that yielded a positive result to the processing.So I would have returned a string not a result set.Moreover I have tried opening cursors within Table Functions.Such attempts are throwing the same error
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group