Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: user defined functions help

Re: user defined functions help

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 11 Feb 1999 01:23:16 GMT
Message-ID: <36c230c1.1252260@192.86.155.100>


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  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US