Home » SQL & PL/SQL » SQL & PL/SQL » Function overloading
Function overloading [message #235533] Mon, 07 May 2007 01:33 Go to next message
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 #235535 is a reply to message #235533] Mon, 07 May 2007 01:39 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

Hi,
You should read documentation first.
https://www.psoug.org/reference/procedures.html

http://www.google.ae/search?hl=en&q=function+overloading+%2B+ORACLE&meta=

http://tahiti.oracle.com

[Updated on: Mon, 07 May 2007 01:48]

Report message to a moderator

Re: Function overloading [message #235538 is a reply to message #235533] Mon, 07 May 2007 01:44 Go to previous messageGo to next message
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 Go to previous messageGo to next message
Frank
Messages: 7880
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 #235551 is a reply to message #235546] Mon, 07 May 2007 02:34 Go to previous messageGo to next message
saibal
Messages: 111
Registered: March 2007
Location: India
Senior Member
Do you mean to say, you cannot have different return types in overloaded functions?

[Updated on: Mon, 07 May 2007 02:35]

Report message to a moderator

Re: Function overloading [message #235555 is a reply to message #235551] Mon, 07 May 2007 03:05 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Not JUST different return types with equal parameters.
Re: Function overloading [message #235556 is a reply to message #235546] Mon, 07 May 2007 03:11 Go to previous message
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
Previous Topic: Packages
Next Topic: MV/snapshot refresh
Goto Forum:
  


Current Time: Sat Dec 10 06:47:44 CST 2016

Total time taken to generate the page: 0.04972 seconds