本帖最后由 kuvske 于 2012-04-03 12:45:05 编辑

解决方案 »

  1.   

    这块不能这样用。
    create or replace procedure serch_sum (sumb11 out number,ddate String)
    is
    begin
    select sum(combank) from bank into sumb11 
    where com=101 and ddate between to_date(ddate||' 00:00:00','yyyy-mm-dd') and to_date(ddate||' 23:00:00','yyyy-mm-dd');
    end;set serveroutput on;
    declare 
    sumb11 number(10) := 0;
    begin
    serch_sum(sumb11, 'aaa');
    dbms_output.put_line(sumb11); --输出结果
    end;
      

  2.   

    把语句修改一下:sumb11 := select sum(combank) 
    from bank 
    where com=101 and 
    ddate between to_date(ddate || ' 00:00:00','yyyy-mm-dd') and to_date(ddate || ' 23:00:00','yyyy-mm-dd')
      

  3.   

    create or replace procedure serch_sum(sumb11 out number, ddate String) is
    begin
      select sum(combank)
        into sumb11
        from bank
       where com = 101
         and ddate between to_date(ddate + ' 00:00:00', 'yyyy-mm-dd') and
             to_date(ddate + ' 23:00:00', 'yyyy-mm-dd');
    end;
      

  4.   

    做个例子给你参考下!
    SQL> create or replace procedure pro_out_test(i_empno in emp.empno%type,o_sal out emp.sal%type) is
      2  begin
      3    select sum(sal)
      4      into o_sal    --把结果赋值给o_sal
      5      from emp
      6     where empno = i_empno;
      7     exception when no_data_found then
      8         dbms_output.put_line('没有员工号'||i_empno||'信息');
      9  end;
     10  /
     
    Procedure created
    SQL> set serveroutput on;
    SQL> declare
      2    v_sal emp.sal%type;
      3    v_empno emp.empno%type;
      4  begin
      5      v_empno := 7369;
      6      pro_out_test(v_empno,v_sal);   --调用pro_out_test过程
      7      dbms_output.put_line('员工号'||v_empno||'的薪水为'||v_sal);
      8  end;
      9  /
     
    员工号7369的薪水为800
     
    PL/SQL procedure successfully completed