日期:2014-05-17  浏览次数:21100 次

怎么将查询结果直接赋给数组呢
原用游标赋值,可发现速度很慢也不稳定,有时11秒,有时50秒左右
代码如下
create   or   replace   procedure   p_Gacalc
(Str_ffrq   in   varchar2,Str_zlid   in   varchar2)
AS
Str_KX   tb_permit_user.kxid%type;
Str_PU_ID   tb_permit_user.pu_id%type;
CURSOR   csor_aaa   IS   select   pu_id,kxid   from   v_mygz   t     ;
begin
/**/
open   csor_aaa;
loop
    fetch   csor_aaa   into   Str_PU_id,Str_KX;
    exit   when   csor_aaa%notfound;  
    update   gzjj   set   xms=(50+40)   where     trim(pu_id)=trim(to_char(Str_PU_id))   and     ffrq=to_date( '2006-08-01 ', 'yyyy-mm-dd ');
  commit;
  /**/end   loop;
close   csor_aaa;
end;


------解决方案--------------------
create or replace procedure p_Gacalc
(Str_ffrq in varchar2,Str_zlid in varchar2)
AS
CURSOR csor_aaa IS select pu_id,kxid from v_mygz t ;
begin
/**/
For tmp_Csor_aaa in csor_aaa Loop
update gzjj set xms=(50+40) where trim(pu_id)=trim(to_char(tmp_Csor_aaa.pu_id)) and ffrq=to_date( '2006-08-01 ', 'yyyy-mm-dd ');
End Loop;
commit;
end;

顺便问一下,没看到你的程序用到这个变量啊(Str_KX tb_permit_user.kxid%type; )