Home » SQL & PL/SQL » SQL & PL/SQL » Function Overloading
Function Overloading [message #238925] Mon, 21 May 2007 00:47 Go to next message
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 #238950 is a reply to message #238925] Mon, 21 May 2007 01:15 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
In PL/SQL, none I am aware of.

Regards
Michel
Re: Function Overloading [message #239156 is a reply to message #238950] Mon, 21 May 2007 10:43 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
check it


www.revealnet.com/pipelines/ExpertFiles/NineNiftyNuances.ppt
Re: Function Overloading [message #239160 is a reply to message #239156] Mon, 21 May 2007 10:53 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Can you tell me where in this document something is said about "Procedure/Function Overloading [...] other than Polymorphism"?

Regards
Michel
Re: Function Overloading [message #239236 is a reply to message #238925] Mon, 21 May 2007 17:08 Go to previous messageGo to next message
William Robertson
Messages: 1640
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 Go to previous messageGo to next message
Frank
Messages: 7880
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 #239326 is a reply to message #239319] Tue, 22 May 2007 01:02 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

Well, I don't know. But this was asked to me in an interview and so i threw the same in to the Forum.
Re: Function Overloading [message #239333 is a reply to message #239319] Tue, 22 May 2007 01:13 Go to previous messageGo to next message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
It's like asking, what is the use of private methods apart from encapsulation?
Re: Function Overloading [message #239336 is a reply to message #239333] Tue, 22 May 2007 01:18 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

Like Java,Does PLSQL support Overriding too?

[Updated on: Tue, 22 May 2007 01:18]

Report message to a moderator

Re: Function Overloading [message #239338 is a reply to message #239336] Tue, 22 May 2007 01:21 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Overriding has nothing to do with overloading.
Overriding involves inheritance, which is not applicable to regular packages.
Re: Function Overloading [message #239339 is a reply to message #239338] Tue, 22 May 2007 01:25 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

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?
Re: Function Overloading [message #239340 is a reply to message #239336] Tue, 22 May 2007 01:27 Go to previous messageGo to next message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
caliguardo wrote on Tue, 22 May 2007 07:18
Like Java,Does PLSQL support Overriding too?

Yes, though this would apply to object types and not packages.
Re: Function Overloading [message #239341 is a reply to message #239339] Tue, 22 May 2007 01:28 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Do we have any specific advantage of Overloading?
Why do we actually go for it?

Same name for same function but different parameter types.
For example, TO_CHAR function.

Regards
Michel

[Updated on: Tue, 22 May 2007 01:29]

Report message to a moderator

Re: Function Overloading [message #239343 is a reply to message #239339] Tue, 22 May 2007 01:33 Go to previous message
William Robertson
Messages: 1640
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.
Previous Topic: HOW TO CURSOR OUT FROM A TEMP TABLE
Next Topic: How do I optimize this query better (than adding hints) (merged)
Goto Forum:
  


Current Time: Sat Dec 10 03:08:35 CST 2016

Total time taken to generate the page: 0.05105 seconds