-1

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

4

2 回答 2

2

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

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;
于 2012-06-21T00:09:13.653 回答
1
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;

希望这可以帮助

于 2012-06-20T18:25:32.287 回答