Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: user defined functions help
A copy of this was sent to Manfred Mann <manfredmann_at_excite.com>
(if that email address didn't require changing)
On Wed, 10 Feb 1999 16:34:32 -0800, you wrote:
>I would like to define a function in Oracle that does the following:
>
>function divret(x,y)
>
>if y = 0 then return 0
>
>else
>
>return x/y
>
>How do I do this? Do I use stored functions?
decode( y, 0, 0, x/y ) would be the fastest in SQL as decode is a builtin...
decode is like an if/then/else if/.... statement.. the above says:
if ( y = 0 ) return 0
else return x/y
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Feb 10 1999 - 19:23:16 CST