当前位置: 代码迷 >> Oracle开发 >> 这个存储过程如何调用
  详细解决方案

这个存储过程如何调用

热度:71   发布时间:2016-04-24 07:24:05.0
请教高手这个存储过程怎么调用?
请教高手这个存储过程怎么调用?
 create OR REPLACE procedure proc_Pope_OneLevel (In_RoleId number,In_Ids varchar2)
 is
 begin
  update ActiveRole set allow=0 where RoleId=In_RoleId and Menu_AId<2000;
  update ActiveRole set allow=1 where RoleId=In_RoleId and Menu_AId in (In_Ids);
 end;
/

exec proc_Pope_OneLevel (9,'1000,1001,1002');

这样调用会报错。
ORA-01722: 无效数字
ORA-06512: 在 "CELE.PROC_POPE_ONELEVEL", line 5
ORA-06512: 在 line 2

能我帮我解释下么,小弟初学Oracle,不太会。

------解决方案--------------------
SQL code
update ActiveRole set allow=1 where RoleId=In_RoleId and Menu_AId in (In_Ids);--这种写法错的In_Ids是一个字符串,而不是几个数字的集合
------解决方案--------------------
SQL code
--试下,有问题再提出create OR REPLACE procedure proc_Pope_OneLevel (In_RoleId number,In_Ids varchar2) isstrsql varchar2(2000); begin  update ActiveRole set allow=0 where RoleId=In_RoleId and Menu_AId<2000;  strsql := 'begin update ActiveRole set allow=1 where RoleId=In_RoleId and Menu_AId in ('||In_Ids||'); end;';  execute immediate strsql; end;/
------解决方案--------------------
update ActiveRole set allow=1 where RoleId=In_RoleId 
and instr(In_Ids,Menu_AId,1)>0;
  相关解决方案