Function with Out parameter [message #469610] |
Thu, 05 August 2010 05:31 |
Genesys
Messages: 45 Registered: August 2010
|
Member |
|
|
Hi All,
iam new to this forum.can any one give the hint regarding the functions.
if function having retrun statement, why we need to use out or inout parameters.
thanks
Genesys
|
|
|
Re: Function with Out parameter [message #469611 is a reply to message #469610] |
Thu, 05 August 2010 05:33 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You don't and you shouldn't.
If you've got IN OUT or OUT parameters in a function then you can't use it in sql.
If you want something with multiple out parameters use a procedure.
|
|
|
|
|
Re: Function with Out parameter [message #469627 is a reply to message #469610] |
Thu, 05 August 2010 06:05 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
Genesys wrote on Thu, 05 August 2010 12:31if function having retrun statement, why we need to use out or inout parameters.
You do not need to use them, they are optional (not mandatory). On the other hand, why (the others) should not use them when they feel they are suitable and its usage complies their coding standards?
|
|
|
Re: Function with Out parameter [message #469629 is a reply to message #469627] |
Thu, 05 August 2010 06:10 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You can use them if you really want to but I really don't see the point.
Since you instantly limit the usage to PL/SQL it's as easy to use a procedure and generally less confusing.
I've seen on more than one occasion people wondering why they can't call functions from SQL.
|
|
|
|
Re: Function with Out parameter [message #469715 is a reply to message #469635] |
Thu, 05 August 2010 11:16 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
The only coding standard (regarding this) I have ever come across always was the other way around: do not use functions with out parameters.
Actually, I cannot think why a coding standard would state you are required to use a function for anything, even if there are out parameters. (Note: talking about standards here, not about the use of the functions itself)
|
|
|
|
Re: Function with Out parameter [message #469733 is a reply to message #469610] |
Thu, 05 August 2010 11:59 |
|
Kevin Meade
Messages: 2103 Registered: December 1999 Location: Connecticut USA
|
Senior Member |
|
|
Well for me the whole point of a function is chaining.
x := strip_first_letter(strip_first_letter(strip_first_letter(x)));
would strip the first three letters from X; If the function is written like this:
function strip_first_letter(in_p in varchar2) return varchar2 is
begin
...
end;
/
it makes some sense; But what does this mean?
function strip_first_letter(
in_p in varchar2
, out1_p out varchar2
, out2_p out varchar2
, out3_p out varchar2
) return varchar2 is
begin
...
end;
/
What does one do with the out parameters when chaining?
Is it even possible to chain?
If a function can't be used to chain and it can't be used in a sql statement, then why make the piece of code a function? Neither of the two reasons for choosing function as the code type work.
Kevin
[Updated on: Thu, 05 August 2010 12:02] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Function with Out parameter [message #469826 is a reply to message #469813] |
Fri, 06 August 2010 00:38 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
The original poster did not ask for what you provided, (s)he asked what use there was in having out parameters in functions.
Now Kevin pointed this out to you, so you repost your useless example. Great. Maybe after this post you can post an example of a packaged function with out parameters.
"Michel wrote"Because in many languages there is ONLY functions and in many entreprises coding standards are the same ones for all languages unless they do not support one of the rules.
But if they were consistent in their standards, they would require a struct return type instead of a scalar + out parameters.
|
|
|
Re: Function with Out parameter [message #469827 is a reply to message #469826] |
Fri, 06 August 2010 00:51 |
|
rahulvb
Messages: 924 Registered: October 2009 Location: Somewhere Near Equator.
|
Senior Member |
|
|
Frank wrote on Fri, 06 August 2010 00:38so you repost your useless example. Great.
May be it is Useless..May be not !!!
Frank wrote on Fri, 06 August 2010 00:38
But if they were consistent in their standards, they would require a struct return type instead of a scalar + out parameters.
????
|
|
|