• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 975
  • Last Modified:

Usage of NOCOPY in database procedures

Hi

We use "NOCOPY" keyword in Oracle database procedures?  Can anyone tell me what is the significance of "NOCOPY"?

Advance thanks

Srigupta
0
srigupta
Asked:
srigupta
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
0
 
zilvaCommented:
When a parameter is passed as an IN variable, it is passed by reference.  Since it will not change, PL/SQL uses the passed variable in the procedure/function.  When variables are passed in OUT or INOUT mode, a new variable is define, and the value is copied to the passed variable when the procedure ends.  If the variable is a large structure such as a PL/SQL table or an array, the application could see a performance degradation cause by copying this structure.
The NOCOPY clause tells to PL/SQL engine to pass the variable by reference, thus avoiding the cost of copying the variable at the end of the procedure.  The PL/SQL engine has requirements that must be met before passing the variable by reference and if those requirements are not met, the NOCOPY clause will simply be ignored by the PL/SQL engine.
If an OUT or INOUT variable is passed by reference (NOCOPY) and the procedure terminates due to an unhandled exception (ends abnormally), the value of the referenced variable may no longer be valid. Both stored procedures and functions are passed variables, the only difference is that a function can only be passed IN variables because a function returns a value.
0
 
sriguptaAuthor Commented:
Hi

Thanks to all for your help.

Srigupta
0
 
slightwv (䄆 Netminder) Commented:
zilva,

For future reference if you're going to copy and paste an answer, please give credit to the original author and at least give the URL:
http://www.remote-dba.net/t_easyoracle_pl_sql_nocopy_clause_inout_variable.htm
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now