Skip to Main Content

SQL & PL/SQL

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!

converting string to a number list

User_Z52BCDec 19 2011 — edited Dec 20 2011
create table pids
(id number, name varchar2(15))
/
insert into pids values (1, 'PTEST1');
insert into pids values (2, 'PTEST2');
insert into pids values (3, 'PTEST3');

create or replace procedure numlist (p_num varchar2) is

	cursor curt is
	select *
	from pids
	where id in (p_num);
begin
for curtr in curt
loop
	dbms_output.put_line('Name is ' || curtr.name);
end loop;
end;
/
when executed, it's giving error which is valid. How to convert a string to a number list.
SQL> exec numlist('1,2');
BEGIN numlist('1,2'); END;

*
ERROR at line 1:
ORA-01722: invalid number
ORA-06512: at "TSEC.NUMLIST", line 8
ORA-06512: at line 1
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2012
Added on Dec 19 2011
4 comments
887 views