Function overloading [message #235533] |
Mon, 07 May 2007 01:33 |
akkumar81
Messages: 144 Registered: February 2007 Location: india
|
Senior Member |
|
|
Dear 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
|
|
|
|
Re: Function overloading [message #235538 is a reply to message #235533] |
Mon, 07 May 2007 01:44 |
saibal
Messages: 111 Registered: March 2007 Location: India
|
Senior Member |
|
|
NOCOPY is a compiler hint that allows IN and IN OUT parameters to be passed by reference rather than value
Function Overloading cannot happen with standalone functions. They have to be put inside a package. Basically, you overload a function by using the same name, but different data types for return values. You can use the same name for different functions if their formal parameters differ in number, order, or datatype family.
|
|
|
Re: Function overloading [message #235546 is a reply to message #235538] |
Mon, 07 May 2007 02:20 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
You can NOT overload a function by defining different return types.
Suppose you have one returning a date and one returning a number.
Now you call a := to_char(myfunction);
How would plsql know which version you meant?
|
|
|
|
|
Re: Function overloading [message #235556 is a reply to message #235546] |
Mon, 07 May 2007 03:11 |
saibal
Messages: 111 Registered: March 2007 Location: India
|
Senior Member |
|
|
That's exactly what I was trying to say--maybe I was not coherent enough.
In fact, to put it differently overloaded functions must differ by more than their return type.
In passing,overloaded function have certain restrictions:
datatype "family" of at least one of the parameters of overloaded programs must differ
Must be defined within the same PL/SQL scope
Parameter list of overloaded programs must differ by more than just the parameter mode
overloaded programs that differ only in name in their parameter lists must be called using named notation
Regards
|
|
|