Home >> FAQs/Tutorials >> Oracle Tutorials

Oracle Tutorials - Use "IN OUT" Parameters

By: FYIcenter.com

(Continued from previous topic...)

How To Use "IN OUT" Parameter Properly?

Here are the rules about IN OUT parameters:

  • A formal IN OUT parameter acts like an initialized variable.
  • An actual IN OUT parameter must be a variable.
  • An actual IN OUT parameter passes a copy of its value to the formal parameter when entering the procedure or function.
  • An actual IN OUT parameter will receive a copy of the value from the formal parameter at the end of the procedure or function.

Here is good example of a procedure with IN OUT parameters:

SQL> CREATE OR REPLACE PROCEDURE SWAP_TEST AS
  2    A NUMBER := 3;
  3    B NUMBER := 8;
  4    PROCEDURE MY_SWAP(X IN OUT NUMBER,Y IN OUT NUMBER) AS
  5      T NUMBER;
  6    BEGIN
  7      T := X;
  8      X := Y;
  9      Y := T;
 10    END MY_SWAP;
 11  BEGIN     
 12    MY_SWAP(A,B);
 13    DBMS_OUTPUT.PUT_LINE('A = ' || TO_CHAR(A));
 14    DBMS_OUTPUT.PUT_LINE('B = ' || TO_CHAR(B));
 15  END;
 16  /

SQL> EXECUTE SWAP_TEST;
A = 8
B = 3

(Continued on next topic...)

  1. What Is a Procedure?
  2. What Is a Function?
  3. How To Define an Anonymous Procedure without Variables?
  4. How To Define an Anonymous Procedure with Variables?
  5. How To Create a Stored Procedure?
  6. How To Execute a Stored Procedure?
  7. How To Drop a Stored Procedure?
  8. How To Pass Parameters to Procedures?
  9. How To Create a Stored Function?
  10. How To Call a Stored Function?
  11. How To Drop a Stored Function?
  12. How To Call a Stored Function with Parameters?
  13. How To Define a Sub Procedure?
  14. How To Call a Sub Procedure?
  15. How To Define a Sub Function?
  16. Can Sub Procedure/Function Be Called Recursively?
  17. What Happens If Recursive Calls Get Out of Control?
  18. What Is the Order of Defining Local Variables and Sub Procedures/Functions?
  19. What Is the Difference between Formal Parameters and Actual Parameters?
  20. What Are the Parameter Modes Supported by PL/SQL?
  21. How To Use "IN" Parameter Properly?
  22. How To Use "OUT" Parameter Properly?
  23. How To Use "IN OUT" Parameter Properly?
  24. How To Define Default Values for Formal Parameters?
  25. What Are Named Parameters?
  26. What Is the Scope of a Local Variable?

Oracle Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...