类似这样一个检索 select count(*)into empCount From emp where empNo in ('001','002','003');
如果in的内容是参数穿进来的一个数组,那语句该怎么写啊?
forall i in in_array.first..in_array.last
select count(*)into empCount From emp where empNo = in_array(i);
编译是通过了,但执行的时候出异常了,说No Data..forall 在Update,Insert,Delete语句中都是可以用的,Select的时候不会了..
如果in的内容是参数穿进来的一个数组,那语句该怎么写啊?
forall i in in_array.first..in_array.last
select count(*)into empCount From emp where empNo = in_array(i);
编译是通过了,但执行的时候出异常了,说No Data..forall 在Update,Insert,Delete语句中都是可以用的,Select的时候不会了..
decalre
l_v varchar2(4000);
l_n int;
begin
.......
.......
for i in in_array.first..in_array.last loop
if i=1 then
l_v:='''||in_array(i)||''';
else
l_v:=l_v||',''||in_array(i)||''';
end if;
end loop;
execute immediate 'select count(*) from emp where empno in ('||l_v||')' into l_n;
.......
.......
难道.. 哎..