不可以的 你可以先把数组中的数据取出组成串1,2,3,4 然后用location_id in (1,2,3,4);
你可以把数组改为,单步处理 return varchar2 as --type t_arr is varray(50000) of varchar2(4); --v_arr t_arr:=t_arr(); cursor t_sor is select location_id from location where llink='0'; t varchar2(4000); cnt number:=0; num number:=1; begin for v_sor in t_sor loop select count(*) into num from tool_and_status where location_id in v_sor.location_id; cnt:=cnt+num ; end loop; ... return t; end;
我并不是只统计记录数,而是select * from table where ...
select count(*) into num from tool_and_status where (location_id in (select location_id from location where llink='0')); 为什么用数组?直接和表匹配就可以了啊?你的函数返回t,t在你的函数中并没有实际意义
你可以先把数组中的数据取出组成串1,2,3,4
然后用location_id in (1,2,3,4);
return varchar2
as
--type t_arr is varray(50000) of varchar2(4);
--v_arr t_arr:=t_arr();
cursor t_sor is select location_id from location where llink='0';
t varchar2(4000);
cnt number:=0;
num number:=1;
begin
for v_sor in t_sor loop
select count(*) into num from tool_and_status where location_id in v_sor.location_id; cnt:=cnt+num ;
end loop;
...
return t;
end;
where (location_id in (select location_id from location where llink='0'));
为什么用数组?直接和表匹配就可以了啊?你的函数返回t,t在你的函数中并没有实际意义