Solved

Usage of NOCOPY in database procedures

Posted on 2007-03-27
4
940 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.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now