Solved

Usage of NOCOPY in database procedures

Posted on 2007-03-27
4
949 Views
Last Modified: 2011-10-03
Hi

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

Advance thanks

Srigupta
0
Comment
Question by:srigupta
  • 2
4 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 18803106
0
 
LVL 2

Accepted Solution

by:
zilva earned 50 total points
ID: 18806022
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
 

Author Comment

by:srigupta
ID: 18810759
Hi

Thanks to all for your help.

Srigupta
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 18811422
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question