为什么我用PL/SQL集合里的exists()方法时一直返回是false啊,从来没返回真。
declare
   type eno_table_type is table of emp.empno%type index by binary_integer;
   eno_table eno_table_type;
 begin
   select empno bulk collect into eno_table from emp;
  if eno_table.exists(7788) then
        dbms_output.put_line('数据正确');
     else
    dbms_output.put_line('数据不正确');
     end if;
 end;
上面一直输出‘数据不正确’。但7788确实是emp表里的一个编号,试了其他的数也不行,一直返回假,没有一次是真。
这是怎么回事啊?期待详解…………

解决方案 »

  1.   

    支持
    这个exists后面的数值表示的是pl/sql表的下标,而不是里面储存的数据
      

  2.   


    declare
      i: Integer;
    begin
      select Count(1) 
        into i
        from dual
       where Exists (select 1  
                       from emp
                      where empno = 7788);
      if i = 0 then
        dbms_output.put_line('数据不正确'); 
      else
        dbms_output.put_line('数据正确');
      end if;
    end; 
      

  3.   

    for i in 1..eno_table.count loop
       if (eno_table(i) = 7788 ) then
           --输出数据正确
       end if;
    end loop;