Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cursor-how to pass (comma separated) -yet single parameter to cursor

450482Aug 14 2008 — edited Aug 15 2008
Hi
I have to get a code for a given id passed to the cursor. There can be multiple id's that could be passed - was thinking a loop will work for that. My code is somewhat like:
declare
CURSOR MY_CUR(C_IDS varchar2) IS 
		SELECT DISTINCT CD as a FROM test1 WHERE idd in (''||c_IDS||'');
rec_t MY_CUR%rowtype;
lp_CD varchar2(30);
begin
  open MY_CUR('1123456');
  loop
  	fetch MY_CUR into rec_t;
    if rec_t.a = 'A123' then
  		lp_CD := 'A123';
  		
  	else
  		lp_CD := 'NONE';
  		
  	end if;

  	exit when MY_CUR%notfound;
  end loop;
end;
/
My question is:
1) How can I pass multiple parameters to the cursor and get the code back for those?
2) How can i test the code above without hardcoding the id?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2008
Added on Aug 14 2008
2 comments
2,866 views