Function Overloading [message #238925] |
Mon, 21 May 2007 00:47  |
caliguardo
Messages: 107 Registered: February 2007 Location: Chennai
|
Senior Member |

|
|
As in other 3G Languages, we have Procedure/Function Overloading in Oracle. What is the actual use of this other than Polymorphism?
|
|
|
|
|
|
Re: Function Overloading [message #239236 is a reply to message #238925] |
Mon, 21 May 2007 17:08   |
William Robertson
Messages: 1643 Registered: August 2003 Location: London, UK
|
Senior Member |
|
|
caliguardo wrote on Mon, 21 May 2007 06:47 | As in other 3G Languages, we have Procedure/Function Overloading in Oracle. What is the actual use of this other than Polymorphism?
|
Isn't Polymorphism another word for Overloading?
Off the top of my head:
You might want to add new functionality to an existing application. You can add a new parameter or alter an existing one (change a character string argument to a DATE or an array for example) while still presenting the old interface to existing code so it continues to work the same way.
You can provide the same code as both a procedure and a function.
I was playing around with some code recently that I wanted to appear like a collection (but was actually a function), and overloading was the answer:
mypackage.myvalues
would return a collection of records, while
mypackage.myvalues(1)
would return a single record.
Someone asked on a forum recently how you could distinguish between a default parameter value that was used because no value was specified, and that actual value being specified for the parameter. Overloading would provide that for you.
|
|
|
Re: Function Overloading [message #239319 is a reply to message #239236] |
Tue, 22 May 2007 00:55   |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
William Robertson wrote on Tue, 22 May 2007 00:08 |
Isn't Polymorphism another word for Overloading?
|
That was my reaction too, when I read this.
Let's put it another way: Caliguardo, what other use would you expect but polymorphism?
|
|
|
|
|
|
|
|
|
|
Re: Function Overloading [message #239343 is a reply to message #239339] |
Tue, 22 May 2007 01:33  |
William Robertson
Messages: 1643 Registered: August 2003 Location: London, UK
|
Senior Member |
|
|
caliguardo wrote on Tue, 22 May 2007 07:25 | I am confused with the difference between the two. Anyhow i will google it....
Do we have any specific advantage of Overloading?
Why do we actually go for it?
|
In addition to my earlier suggestions, you mean?
Overloading means that the same function/procedure can behave differently (call different code) when given different parameters, e.g.
dosomething(SYSDATE)
and
dosomething(42)
would actually invoke completely different versions of the "dosomething" procedure.
Overriding is when a subtype provides a different version of a method defined in its supertype.
|
|
|