|
Home > Archive > Oracle certifications > May 2002 > functions question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
functions question
|
|
| ying_yo 2002-05-21, 3:27 pm |
| can functions take OUT and IN OUT parameters and get successfully compiled and executed?
i am getting confused with this,some books are saying something and some are something else...i tried but.... | |
| mhusain 2002-05-22, 8:58 am |
| quote: Originally posted by ying_yo
can functions take OUT and IN OUT parameters and get successfully compiled and executed?
i am getting confused with this,some books are saying something and some are something else...i tried but....
U create a function when u want to compute a value, which must be returned to the calling environment thru RETURN. A function can contain zero or more parameters that r transferred from the calling environment. A function should only return a single value, and one should not declare OUT and IN OUT parameters for a function
I hope this help.
Mohammad | |
| Skating Zebra 2002-05-22, 9:46 am |
| A stored procedure can be written to accept zero, one, or multiple parameters, and these parameters can be defined as IN, OUT, or IN OUT. An IN parameter is only used to pass a value into the stored procedure, an OUT parameter is used to pass a value out of a stored procedure, and an IN OUT parameter can be used to pass a value both ways. By using multiple OUT or IN OUT parameters, a stored procedure can return multiple values.
In PL/SQL, a function is a special type of stored program unit that returns one, and only one, value. A function can accept zero, one, or multiple parameters, depending on how it is coded. For example, the PL/SQL function
UPPER(string_expression)
takes one input parameter (a string expression) and returns the uppercase value of the string. A function returns a single value identified by the RETURN keyword at the end of the CREATE FUNCTION statement.
Functions should not use OUT or IN OUT parameters; instead, they should use the RETURN keyword to return a single value. I believe that functions are ABLE to use OUT and IN OUT parameters, but it is considered a poor programming practice to use these types of parameters in a function. If you need to return more than one value, write a stored procedure instead.
For more detailed information check out Chapter 10 of "Oracle8i Application Developer's Guide - Fundamentals" in the generic Oracle documentation.
Hope this helps! |
|
|
|
|