Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL OUT Keyword      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: OUT

Definition:
In Oracle PL/SQL, the term OUT refers to one of the parameter passing modes. Unlike the IN parameter mode, it must be specified in the parameter declaration. An OUT parameter is a 'pass by value' method. The parameter must be assigned with a value within the subprogram body. This value is then passed to the host environment, from where the subprogram has been called.

Notes

  1. A default value cannot be assigned to the OUT parameter.
  2. The NOCOPY hint can be used in the parameter declaration to convert the parameter calling method from 'Call by Value' method to the 'Call by reference' method.

Example Syntax:

PARAMETER [IN | OUT | IN OUT] [DATA TYPE] [DEFAULT],


Example Usage:

The procedure P_GET_SAL fetches the salary of an employee from EMPLOYEE table for the given employee id and returns it to the calling environment.

CREATE OR REPLACE PROCEDURE P_GET_SAL (P_EMPID NUMBER, P_SAL OUT NUMBER)
IS
BEGIN
SELECT SALARY
INTO P_SAL
FROM EMPLOYEE
WHERE EMPLOYEE_ID=P_EMPID;
END;


Functionally, the code above may be used as in this example:

SQL> VAR G_SAL NUMBER;
SQL> EXEC P_GET_SAL(100,:G_SAL);

PL/SQL procedure successfully completed.

SQL> PRINT G_SAL;

G_SAL
----------
2300



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 131 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?