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

Home -> Community -> Usenet -> c.d.o.server -> Re: Conversion from string to number with a default value

Re: Conversion from string to number with a default value

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Fri, 28 May 2004 22:32:50 -0700
Message-ID: <1085808777.808363@yasure>


Chandresh Prakash wrote:

> Hi,
> Does anyone know an sql function to convert a string to a number and if the
> string is not a number then converting to a default numeric value in Oracle.
> For example, something like to_number('234',-1) = 234 and
> to_number('34a',-1) = -1.
>
> Thanks in advance,
> Chandresh

You'll need to write your own function. But I'd take a good look at cast.

Go to: http://www.psoug.org/reference/library.html and click on CAST.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Sat May 29 2004 - 00:32:50 CDT

Original text of this message

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