create or replace procedure pro_selMenu_PK
(
ids in varchar2 --要删除的串
)
is
Cursor module_Cursor is select name from tableName where id in (ids);
....
当我从外面传1,2,3时 module_Cursor得不到值
但是我在这里写死的时候 好好的,游标会有值
Cursor module_Cursor is select name from tableName where id in (1,2,3);
请问我是不是传参不对 我要怎么传。而且我传单个值它也对了 就是不是多个值的时候 如传一个1他持选择 挺好.
------解决方案--------------------
这样试试
- SQL code
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)
------解决方案--------------------
- SQL code
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
------解决方案--------------------