日期:2014-05-17 浏览次数:20922 次
Cursor module_Cursor is select name from tableName where id in ( select replace(regexp_substr(ids,'[^,]+',1,level),',',' ') c1 from t1 connect by level<=length(ids)-length(replace(ids,',',''))+1 )
------解决方案--------------------
create or replace procedure pro_test(ids in varchar2) as v_sql varchar2(100); type cus_t_type is ref cursor; cur_t cus_t_type; v_name varchar2(20); begin v_sql := 'select name from t where id in ('||ids||')'; open cur_t for v_sql; fetch cur_t into v_name; loop exit when cur_t%notfound; dbms_output.put_line(v_name); fetch cur_t into v_name; end loop; close cur_t; end; SQL> exec pro_test('1,2,3'); 张3 李4 王5 PL/SQL procedure successfully completed
------解决方案--------------------