| Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) Part Number E17126-03 |
|
|
View PDF |
A formal parameter declaration can appear in the following:
Topics:
Syntax
parameter_declaration ::=

See:
Semantics
parameter_name
The name of the formal parameter that you are declaring, which you can reference in the executable part of the subprogram.
IN, OUT, IN OUT
Mode that determines the behavior of the parameter, explained in "Subprogram Parameter Modes". The default is IN.
Note:
Avoid usingOUT and IN OUT for function parameters. The purpose of a function is to take zero or more parameters and return a single value. Functions must be free from side effects, which change the values of variables not local to the subprogram.Requests that the compiler pass the corresponding actual parameter by reference instead of value (for the difference, see "Subprogram Parameter Passing Methods"). Each time the subprogram is invoked, the optimizer decides, silently, whether to obey or disregard NOCOPY.
Caution:
NOCOPY increases the likelihood of aliasing. For details, see "Subprogram Parameter Aliasing with Parameters Passed by Reference".The compiler always ignores NOCOPY in the following cases:
The actual parameter must be implicitly converted to the data type of the formal parameter.
The actual parameter is the element of an associative array.
The actual parameter is a scalar variable with the NOT NULL constraint.
The actual parameter is a scalar numeric variable with a range, size, scale, or precision constraint.
The actual and formal parameters are records, one or both was declared with %ROWTYPE or %TYPE, and constraints on corresponding fields differ.
The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields differ.
The subprogram is invoked through a database link or as an external subprogram.
datatype
The data type of the formal parameter that you are declaring. If datatype is a constrained subtype, the corresponding actual parameter inherits the NOT NULL constraint of the subtype (if it has one), but not the size (see Example 8-10).
Caution:
The data typeREF CURSOR increases the likelihood of subprogram parameter aliasing, which can have unintended results. For more information, see "Subprogram Parameter Aliasing with Cursor Variable Parameters".expression
Specifies the default value for the formal parameter. The data types of expression and the formal parameter must be compatible.
If a subprogram invocation does not specify an actual parameter for the formal parameter, then that invocation evaluates expression and assigns its value to the formal parameter.
If a subprogram invocation does specify an actual parameter for the formal parameter, then that invocation assigns the value of the actual parameter to the formal parameter and does not evaluate expression.
Examples
Example 2-26, "Assigning Values to Variables as Parameters of a Subprogram"
Example 8-12, "IN, OUT, and IN OUT Parameter Values Before, During, and After Procedure Invocation"
Example 8-13, "OUT and IN OUT Parameter Values After Unhandled Exception"
Example 8-18, "Formal Parameter with Default Value Returned by Function"
Example 8-19, "Adding Subprogram Parameter Without Changing Existing Invocations"
Related Topics
In this chapter:
In other chapters: