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他持选择 挺好.
(
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他持选择 挺好.
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
什么不懂呢? 就是将传进来的ids以逗号为分割点 将一个字符串分割成多行的了
通过学习 我觉得第一个replace是不是可以去掉?不知道您是用来做什么