【问题标题】:Variable from an procedure to the parameter of another procedure从一个过程到另一个过程的参数的变量
【发布时间】:2012-06-20 17:48:05
【问题描述】:

使用包,我如何将一个过程中的变量赋值传递给另一个过程的参数?

【问题讨论】:

  • 我不明白你在问什么。您的包裹是什么样的,您尝试过什么,遇到了什么问题?

标签: oracle parameters plsql package procedure


【解决方案1】:

我不确定您是否想知道全局变量或 OUT 参数的工作原理。下面是使用过程的 OUT 参数的示例。更多关于使用 IN 和 OUT 的信息可以找到here

create or replace package TEST_PKG
IS
    procedure test(p_input IN NUMBER, p_output OUT NUMBER)
    IS
    BEGIN
        p_output := p_input * p_input;
    END test ;

    procedure testRun
    IS
        v_input NUMBER := 0;
        v_output NUMBER;
    BEGIN
        test(v_input, v_output);
        DBMS_OUTPUT.PUT_LINE('OUTPUT : ' || v_output );
    END test ;
END xyz;

【讨论】:

    【解决方案2】:
    create or replace package xyz
    IS
      procedure test 
      IS
       v_temp varchar2(20); --local variable
      BEGIN
        v_temp:=20; --assigning value to a variable
    
      --if procedure is within the same package,as this example shows ,then call as below  
      test2(v_temp);
    
      --if procedure is in another package say PQR then call as below,
      --but the procedure should be declared in the specification of the package PQR
      PQR.test2(v_temp);  
    
      --if procedure is not inside any package ,just a single procedure is there
      --,then call as below
      test2(v_temp);
    
       END test ;
    
       procedure test2(p_temp IN varchar2)
       IS
       BEGIN
       --do you processing
       END test2;
     END xyz;
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 1970-01-01
      • 2019-10-13
      • 2014-10-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多