OPEN O_OUTCURSOR FOR
         SELECT ipcnt INTO R_Number1  FROM US_DAYREPORT a 
         INNER JOIN AD_MONPOINT b on a.pointid = b.pointid
         and b.name LIKE '%注册%' WHERE a.arrid = I_ArrangeID
         and a.accesstime = trunc(sysdate-1);
         V_Register1 := V_Register1 + R_Number1;
请问我这样能实现累加吗

解决方案 »

  1.   

    错了。
    OPEN O_OUTCURSOR FOR 
            SELECT ipcnt  FROM US_DAYREPORT a 
            INNER JOIN AD_MONPOINT b on a.pointid = b.pointid 
            and b.name LIKE '%注册%' WHERE a.arrid = I_ArrangeID 
            and a.accesstime = trunc(sysdate-1); 
    fetch o_outcursor into R_Number1 ;
    V_Register1 := V_Register1 + R_Number1; 
      

  2.   

    多条数据循环的吧,你的查询结果应该不只是一条纪录呢,
    是步是这个意思:
    SQL> set serveroutput on;
    SQL> 
    SQL> declare
      2    V_Register1 int;
      3  begin
      4    V_Register1 := 0;
      5    for rec in(select salary from hr.employees)
      6    loop
      7      V_Register1 := V_Register1+rec.salary;
      8    end loop;
      9    Dbms_Output.put_line(V_Register1);
     10  end;
     11  /691400PL/SQL procedure successfully completed