This procedure takes a single OUT. Out parameter is assignable : Parameter OUT « Stored Procedure Function « Oracle PL / SQL






This procedure takes a single OUT. Out parameter is assignable

    

SQL> CREATE OR REPLACE PROCEDURE ModeOut (p_Out OUT NUMBER) AS
  2     v_LocalVariable NUMBER := 0;
  3   BEGIN
  4     IF (p_Out IS NULL) THEN
  5       DBMS_OUTPUT.PUT_LINE('p_Out is NULL');
  6     ELSE
  7       DBMS_OUTPUT.PUT_LINE('p_Out = ' || p_Out);
  8     END IF;
  9
 10     p_Out := 7;
 11
 12     v_LocalVariable := p_Out;
 13
 14      DBMS_OUTPUT.PUT('At end of ModeOut: ');
 15     IF (p_Out IS NULL) THEN
 16       DBMS_OUTPUT.PUT_LINE('p_Out is NULL');
 17     ELSE
 18       DBMS_OUTPUT.PUT_LINE('p_Out = ' || p_Out);
 19     END IF;
 20   END ModeOut;
 21   /

Procedure created.

SQL>
SQL>
SQL>
SQL> show errors
No errors.
SQL>
SQL>
SQL> DECLARE
  2     v_Out NUMBER := 1;
  3   BEGIN
  4     
  5     DBMS_OUTPUT.PUT_LINE('Before calling ModeOut, v_Out = ' || v_Out);
  6     ModeOut(v_Out);
  7     DBMS_OUTPUT.PUT_LINE('After calling ModeOut, v_Out = ' || v_Out);
  8   END;
  9   /
Before calling ModeOut, v_Out = 1
p_Out is NULL
At end of ModeOut: p_Out = 7
After calling ModeOut, v_Out = 7

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>

   
    
    
    
  








Related examples in the same category

1.Define 'out' parameters
2.Using out parameter
3.Use out parameter to get value out
4.Parameter Modes
5.Out with NOCOPY modifier.
6.Unhandled exceptions and OUT variables
7.behavior of unhandled exceptions and OUT variables.
8.Behavior of OUT variables and raised exceptions
9.Using Output Parameters
10.Out parameter is assignable