要在oracle的存储过程中,实现这样一个功能:从一个表中找,一个字段的值是否有与结定变量值相同。我现在用的是count into。如:select count(1) into a from table1 where table1.id='001'.
功能可以实现,但由于数据量较大,时间比较长。有人说count是全表索引,很费时,但我改成用时标,这样:
cursor Cur_a is select id from table1  t where t.id='001'
  flag:=0;
  open Cur_a;  
  fetch Cur_a into Cur_a_V;
       if Cur_a%found then
          flag:=1;
       end if;
  close Cur_a;
可测试发现,更费时,可以是每次都要操作游标,高手们有没有好办法,请指教,在线关注,解决就结贴,谢谢!