create or replace procedure pro2
(a in int :=0,b in int :=0,c out int)
is
c int :=0;
begin
  c:=a+b;
end;
--调用
declare
  a int;
  b int;
  c int;
begin
  a := 100;
  b := 200;
  pro2(a, b, c);
dbms_output.put_line(c);
end;

解决方案 »

  1.   


    x_wy46 你好,我想要的是在function中调用这个存储过程,你给的是在另一个存储过程中调用。
      

  2.   

    x_wy46 ,不好意思,看错了,其实我不明白的是在function中要如何去调用,因为我想要的结果是最后直接用一条sql就实现了取到存储过程中的ID,如:select function from dual;就能够看到我取到的值是多少了。
      

  3.   

    另外在直接调用带输出参数的存储过程的时候,只看到提示存储过程已经执行成功,但是看不到输出结果,如下所示:
    SQL> declare
      2  kk varchar2(100);
      3  begin
      4  PRO_GET_NEXTID_BYCONFIG('GX_SYSTEM_FUNCTION','FUNCTION_ID',kk);
      5  dbms_output.put_line(kk);
      6  end;
      7  /
     
    PL/SQL procedure successfully completed
      

  4.   

    在执行set serveroutput on以后,使用dbms_output方法才可以输出信息
      

  5.   


    --创建过程
    create or replace procedure pro2
    (a in int :=0,b in int :=0,c out int)
    is
    c int :=0;
    begin
      c:=a+b;
    end;--创建函数,调用上面的存储过过程,接受存储过程的返回值
    CREATE OR REPLACE FUNCTION fun_test RETURN id integer IS
    declare  a int;
      b int;
      c int;
    BEGIN
      begin
        a := 100;
        b := 200;
        pro2(a, b, c);
        id := c;
        return;
      END fun_test;--测试
    select fun_test() from dual--ps:我也是刚开始写plsql,都是简单的例子,自己也练练手
      

  6.   

    什么意思?求解释!本人有点小白,请bw555详细解释,最好代码对照说明,谢谢!
    下面是set前后的显示差异,测试工具为sqlplus
    SQL> begin
      2  dbms_output.put_line('hello world');
      3  end;
      4  /PL/SQL 过程已成功完成。SQL> set serveroutput on
    SQL> begin
      2  dbms_output.put_line('hello world');
      3  end;
      4  /
    hello worldPL/SQL 过程已成功完成。SQL>
      

  7.   

    很感谢x_wy46 和bw555 两位的热心解答,按照x_wy46 的方法已经解决了我的要求,再次感谢!