469,356 Members | 2,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Function Overloading

kiss07
99
Dear debas and friends,

1)what is the use of NOCOPY parameter?

2)function overloading
-------------------------------
which are the correct function overloading:


1) function f1(c in number)
return number
function f2(c in number)
return number

2) function f1(c in varchar)
return number
function f2(c in varchar)
return number


3)function f1(c in number)
return varchar
function f2(c in number)
return varchar


4)function f1(c in varchar)
return varchar
function f2(c in number)
return number

5) function f1(c in varchar)
return varchar
function f2(c in varchar)
return varchar

6) function f1(c in number)
return varchar
function f2(c in varchar)
return varchar

7)function f1(c in number)
return number
function f2(c in varchar)
return varchar

8)function f1(c in varchar)
return number
function f2(c in varchar)
return varchar

9)function f1(c in number)
return varchar
function f2(c in varchar)
return number


10)function f1(c in varchar)
return number
function f2(c in number)
return varchar

11)function f1(c in varchar)
return varchar
function f2(c in number)
return varchar

12)function f1(c in number)
return number
function f2(c in number)
return varchar


13)function f1(c in varchar)
return varchar
function f2(c in varchar)
return number


14)function f1(c in number)
return varchar
function f2(c in varchar)
return varchar


Thanks and reply..

Arun
May 7 '07 #1
6 11168
debasisdas
8,127 Expert 4TB
Function overloading means 2 or more functions with same name but with different signature.

In oracle function overloading can only be defined with in package.

None of your ex shows function overloading as name is different.
May 7 '07 #2
debasisdas
8,127 Expert 4TB
Example of FUNCTION OVERLOADING
-------------------------------------------------------------
Package specification
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE PKG_UTIL
  2. AS
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER;
  4. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE;
  5. END PKG_UTIL;
  6.  
Package body
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE BODY PKG_UTIL AS
  2.  
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER IS
  4. BEGIN
  5. RETURN ROUND((DT-TO_DATE('01011970','MMDDYYYY'))*86400);
  6. END TRANS_DATE;
  7.  
  8. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE IS
  9. BEGIN
  10. RETURN (TO_DATE('01011970','MMDDYYYY') +(DT/(86400)));
  11. END TRANS_DATE;
  12.  
  13. END PKG_UTIL;
  14.  
In this case the name of both the functions are same
But their signature is different.
while the first function accepts a date as parameter and returns a number
the 2nd accepts a number and returns a date.
May 7 '07 #3
debasisdas
8,127 Expert 4TB
The NOCOPY compiler hint increases the possibility of aliasing (that is, having two different names refer to the same memory location). This can occur when a global variable appears as an actual parameter in a subprogram call and then is referenced within the subprogram. The result is indeterminate because it depends on the method of parameter passing chosen by the compiler.

If you exit a subprogram successfully, PL/SQL assigns values to OUT parameters. However, if you exit with an unhandled exception, PL/SQL does not assign values to OUT parameters (unless they are NOCOPY parameters).
May 7 '07 #4
debasisdas
8,127 Expert 4TB
Restrictions on NOCOPY
=============================
The use of NOCOPY increases the likelihood of parameter aliasing.
Remember, NOCOPY is a hint, not a directive. In the following cases, the PL/SQL compiler ignores the NOCOPY hint and uses the by-value parameter-passing method;
No error is generated:
■ The actual parameter is an element of an associative array. This restriction does not apply if the parameter is an entire associative array.

■ The actual parameter is constrained, such as by scale or NOT NULL. This restriction does not apply to size-constrained character strings. This restriction does not extend to constrained elements or attributes of composite types.

■ The actual and formal parameters are records, one or both records were declared using %ROWTYPE or %TYPE, and constraints on corresponding fields in the records differ.

■ The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields in the records differ.

■ Passing the actual parameter requires an implicit datatype conversion.

■ The subprogram is called through a database link or as an external procedure.


Arun I Hope this much will suffice your purpose.
May 7 '07 #5
r035198x
13,262 8TB
Restrictions on NOCOPY
=============================
The use of NOCOPY increases the likelihood of parameter aliasing.
Remember, NOCOPY is a hint, not a directive. In the following cases, the PL/SQL compiler ignores the NOCOPY hint and uses the by-value parameter-passing method;
No error is generated:
■ The actual parameter is an element of an associative array. This restriction does not apply if the parameter is an entire associative array.

■ The actual parameter is constrained, such as by scale or NOT NULL. This restriction does not apply to size-constrained character strings. This restriction does not extend to constrained elements or attributes of composite types.

■ The actual and formal parameters are records, one or both records were declared using %ROWTYPE or %TYPE, and constraints on corresponding fields in the records differ.

■ The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields in the records differ.

■ Passing the actual parameter requires an implicit datatype conversion.

■ The subprogram is called through a database link or as an external procedure.


Arun I Hope this much will suffice your purpose.
This helped me a lot. Thanks debas.
May 7 '07 #6
kiss07
99
oohh, well and good..

thanks,

Arun..
May 7 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Dave Theese | last post: by
39 posts views Thread by zeus | last post: by
45 posts views Thread by JaSeong Ju | last post: by
7 posts views Thread by asdf | last post: by
15 posts views Thread by lordkain | last post: by
10 posts views Thread by subramanian100in | last post: by
10 posts views Thread by Matthew | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.