Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) Part Number E10472-02 |
|
|
View PDF |
A parameter declaration can appear in in following:
Topics:
Syntax
parameter_declaration ::=
See:
Semantics
datatype
The data type of the parameter that you are declaring.
Restriction on datatype You cannot constrain this data type (with NOT
NULL
, for example).
expression
Specifies an initial value for an IN
parameter. If the invoker of the subprogram specifies a value for the parameter, then expression
is not evaluated for that invocation (see Example 8-8). Otherwise, the parameter is initialized to the value of expression
. The value and the parameter must have compatible data types (see Table 3-10, "Possible Implicit PL/SQL Data Type Conversions").
IN, OUT, IN OUT
Parameter modes that define the action of formal parameters. For summary information about parameter modes, see Table 8-1.
Note:
Avoid usingOUT
and IN
OUT
with functions. 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.NOCOPY
Specify NOCOPY
to instruct the database to pass this argument as fast as possible. This clause can significantly enhance performance when passing a large value like a record, an associative array, or a varray to an OUT
or IN
OUT
parameter. IN
parameter values are always passed NOCOPY
.
When you specify NOCOPY
, assignments made to a package variable may show immediately in this parameter, or assignments made to this parameter may show immediately in a package variable, if the package variable is passed as the actual assignment corresponding to this parameter.
Similarly, changes made either to this parameter or to another parameter may be visible immediately through both names if the same variable is passed to both.
If the subprogram is exited with an unhandled exception, then any assignment made to this parameter may be visible in the caller's variable.
These effects might not occur on any particular call. Use NOCOPY
only when these effects would not matter.
parameter_name
The name of the formal parameter that you are declaring, which you can reference in the body of the subprogram.
Examples
Example 2-27, "Assigning Values to Variables as Parameters of a Subprogram"
Example 8-8, "Formal Parameter with Expression as Initial Value"
Related Topics
In this chapter:
In other chapters: