Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question, Rajesh.
Asked: August 05, 2016 - 3:05 pm UTC
Last updated: August 08, 2016 - 4:16 am UTC
Version: 11G
Viewed 1000+ times
SQL> drop table T1 purge; Table dropped. SQL> SQL> create table t1 ( userid int, cityid varchar2(10)); Table created. SQL> SQL> insert into t1 values (101 ,'BLR'); 1 row created. SQL> insert into t1 values (104 ,'CTC'); 1 row created. SQL> insert into t1 values (103 ,'DEL'); 1 row created. SQL> insert into t1 values (104 ,'BLR'); 1 row created. SQL> insert into t1 values (105 ,'NSK'); 1 row created. SQL> insert into t1 values (101 ,'CTC'); 1 row created. SQL> insert into t1 values (103 ,'BLR'); 1 row created. SQL> SQL> create or replace 2 procedure list_users(p_cities sys.odcivarchar2list) is 3 begin 4 for i in ( 5 select * 6 from t1 7 where cityid in ( select column_value from table(p_cities)) 8 ) 9 loop 10 dbms_output.put_line(i.userid||','||i.cityid); 11 end loop; 12 end; 13 / Procedure created. SQL> SQL> set serverout on SQL> exec list_users(sys.odcivarchar2list('BLR')); 103,BLR 104,BLR 101,BLR PL/SQL procedure successfully completed. SQL> exec list_users(sys.odcivarchar2list('BLR','DEL')); 103,BLR 104,BLR 101,BLR 103,DEL PL/SQL procedure successfully completed. SQL> SQL> SQL>
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library