Saturday 25 May 2013

What is NOCOPY parameter

When you use a Collection (Records, VARRAY etc having records of data) as a Return type (OUT or IN OUT parameter) as we know, it will be passed by value only. That means the entire data will be copied to the formal parameter location, which leads to lot of CPU and memory consumption.

Here comes the usage of NOCOPY parameter. Provide NOCOPY after the OUT/IN OUT parameter, which instructs the PL/SQL Engine to avoid using the pass by value method. So, the Engine uses pass by reference instead. This helps reducing a lot of CPU usage as well as memory consumption.
Eg: Just an example how to put the NOCOPY parameter.

PROCEDURE PRC_NOCOPY_EXAMPLE
(
P_EMPNO IN NUMBER,
P_ENAME IN VARCHAR2(50),
P_SAL OUT NOCOPY RECORD_SAL --PL/SQL Record
);
REC_SAL RECORD_SAL;

Now if you call the Procedure PRC_NOCOPY_EXAMPLE, the parameter P_SAL would only use Pass by reference method.

No comments:

Post a Comment