create or replace procedure sp_check_to_et(
wf_id_in in number,
form_data_id_in in number,
et_id in varchar2
-- return_code out number,
--return_desc out varchar2
)
as
type c_array is table of varchar2(10) index by binary_integer;
p number default 0;
idx number default 0;
strc varchar2(500);
ca c_array;
et_id2 varchar(500);
begin strc:=et_id;
loop
p:=instr(strc,'-',1);
exit when p=0;
ca(idx):=substr(strc,1,p-1)||',';
dbms_output.put_line(ca(idx));
idx:=idx+1; p:=instr(strc,'|',1);
exit when p=0;
strc:=substr(strc,p+1,length(strc));
end loop;
declare
cursor indexs
is
select status_id from ecl_request_sheet where request_id in(ca(idx)) and container_type=4 ;
--定义一个游标变量
c_row indexs%rowtype;begin
open indexs;
loop
fetch indexs into c_row;
exit when indexs%notfound;
if c_row.status_id<>6 then
-- return_code:=1;
-- return_desc:='销售合同未结束';
dbms_output.put_line('OK');
else
-- return_code:=0;
dbms_output.put_line('NO');
end if;
end loop; --关闭游标
close indexs;
end; COMMIT; EXCEPTION WHEN OTHERS THEN
ROLLBACK;
RAISE;END;请问我这样里有什么问题。。上面是截取数据
类似101532-国外出差审批流程 [ 0|P,106-管理员 ] |101530-国外出差审批流程 [ 0|P,106-管理员 ]
这样两条 我只取它们的ID:101530,101532
中间写的显示游标。获得多列查询我截取出来的保存变量不能作为条件查询么?
错误是未找到任何数据。
select status_id from ecl_request_sheet where request_id in(ca(idx)) and container_type=4 ; 我把in后面的 换成(101530,101532)写死又可以。。逻辑是这样:我要截取ID作为条件查询。。
我本来才接触oracle3个多月
求大神解决下。没多少分,,可以加我QQ发福利神马的。
感激不尽存储
wf_id_in in number,
form_data_id_in in number,
et_id in varchar2
-- return_code out number,
--return_desc out varchar2
)
as
type c_array is table of varchar2(10) index by binary_integer;
p number default 0;
idx number default 0;
strc varchar2(500);
ca c_array;
et_id2 varchar(500);
begin strc:=et_id;
loop
p:=instr(strc,'-',1);
exit when p=0;
ca(idx):=substr(strc,1,p-1)||',';
dbms_output.put_line(ca(idx));
idx:=idx+1; p:=instr(strc,'|',1);
exit when p=0;
strc:=substr(strc,p+1,length(strc));
end loop;
declare
cursor indexs
is
select status_id from ecl_request_sheet where request_id in(ca(idx)) and container_type=4 ;
--定义一个游标变量
c_row indexs%rowtype;begin
open indexs;
loop
fetch indexs into c_row;
exit when indexs%notfound;
if c_row.status_id<>6 then
-- return_code:=1;
-- return_desc:='销售合同未结束';
dbms_output.put_line('OK');
else
-- return_code:=0;
dbms_output.put_line('NO');
end if;
end loop; --关闭游标
close indexs;
end; COMMIT; EXCEPTION WHEN OTHERS THEN
ROLLBACK;
RAISE;END;请问我这样里有什么问题。。上面是截取数据
类似101532-国外出差审批流程 [ 0|P,106-管理员 ] |101530-国外出差审批流程 [ 0|P,106-管理员 ]
这样两条 我只取它们的ID:101530,101532
中间写的显示游标。获得多列查询我截取出来的保存变量不能作为条件查询么?
错误是未找到任何数据。
select status_id from ecl_request_sheet where request_id in(ca(idx)) and container_type=4 ; 我把in后面的 换成(101530,101532)写死又可以。。逻辑是这样:我要截取ID作为条件查询。。
我本来才接触oracle3个多月
求大神解决下。没多少分,,可以加我QQ发福利神马的。
感激不尽存储
strsql varchar2(200);
syscursor sys_refcursor;
begin
strsql := 'select status_id from ecl_request_sheet where request_id in(' ||
ca(idx) || ') and container_type=4';
open syscursor for strsql; --通过游标打开动态sql
dbms_output.put_line(strsql);--将拼装后的sql打印出来
loop
...
end loop;
end;
楼主试试这个
把sql贴出来看看就知道了
不能执行的意思是 报错了?
call sp_check_to_et();
执行的时候报错?
你把request_id in(ca(idx)) 换成 request_id in(101530,101532)就不报错?
开一个test窗口 然后一步一步往下走 看看走到哪一行报错了
我这边没有你的数据 没法看或者你把现在最终的存储过程贴出来 我看看
sp_check_to_et('101544','60060','101518-销售合同评审流程 [ HTP-20130114-001 ] |101470-销售合同评审流程 [ HTP-20130109-001 ]');
end;
提示无效数据
给ca赋值的时候 只附了ca(0)和ca(1) 但是你的idx已经变成2了吧
cursor里 ca(idx)就是ca(2) 当然报错了