dbTalk Databases Forums  

'Cursor not in a valid state'

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss 'Cursor not in a valid state' in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pradeep
 
Posts: n/a

Default 'Cursor not in a valid state' - 10-29-2007 , 07:20 AM






Hello all,

I am facing a problem when running the following function:

alter FUNCTION rowtocol( IN qry varchar(4000),p_dlmtr
varchar(10) DEFAULT ',' ) RETURNS varchar
BEGIN
DECLARE lc_colval VARCHAR(4000);
DECLARE lc_str VARCHAR(32767);
DECLARE CUR_REC CURSOR USING qry;
DECLARE err_notfound
EXCEPTION FOR SQLSTATE '02000';
SET lc_colval='';
SET lc_str='';
message 'qry='||qry to client;
message 'before cursor' to client;
OPEN CUR_REC;
notes_loop:
LOOP
FETCH CUR_REC INTO lc_colval;
if SQLstate <> 0 then leave notes_loop;
end if;
message 'inside cursor' to client;
set lc_str=lc_str || p_dlmtr || lc_colval;
message 'lc_str='||lc_str to client;
END LOOP notes_loop;
CLOSE cur_rec;
RETURN SUBSTR(lc_str,2);
EXCEPTION
WHEN OTHERS THEN
message ' Others sqlstate = ',sqlstate to
client;
END;

I am getting an error 'Cursor not in a valid state' when I
try to run this function. Also, when I try using sqlcode =
err_notfound, then it goes into an infinite loop.

SQL Anywhere Version: 10.0.0.2829

Could anyone please check and suggest a solution?

Thanks,
Pradeep

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.