aspose file tools*
The moose likes JDBC and the fly likes [SQL] varchar2 to number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "[SQL] varchar2 to number" Watch "[SQL] varchar2 to number" New topic
Author

[SQL] varchar2 to number

Michael Houlo
Ranch Hand

Joined: Jun 07, 2010
Posts: 58
Hello guys,

In one of my tables, i have a varchar2 column.
This column contains numbers and null values . (hm yeah..)

I'm trying to compare this field with some constant such as "column > 50".
I tryed this :

I even tryed to merge it with trim,nvl & to_char functions but i still can't get a good result..


ps= Nombre non valide = unvalid number.. :P
Stephan Mueller
Ranch Hand

Joined: May 05, 2010
Posts: 50
The number-pattern you are using is invalid, or to be correct, is invalid for your use-case as such that
it doesn't reflect the pattern of the actual values.
Assuming that you are using Oracle (be aware that this is not covered by the SQL standard afaik),
please have a look at http://www.di.unipi.it/~ghelli/didattica/bdldoc/B19306_01/server.102/b14200/functions191.htm
on how to correctly use the to_number function.


1. Make it run - 2. Make it run correctly - 3. Make it pretty OR fast/small - 4. ??? - 5. Profit
Michael Houlo
Ranch Hand

Joined: Jun 07, 2010
Posts: 58
I had to use
to_number(field,'99.999999999','NLS_NUMERIC_CHARACTERS=''. ''')
together with a TRIM..

Thanks anyway
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [SQL] varchar2 to number
 
Similar Threads
How to Determine Whether to Insert or Update
SQL statement to java
Concatination 3 columns of VARCHAR2(4000) to return a ResultSet with one column
Oracle JDBC Thin Client behaviour concerning date data types and it's format.
How to link a function with jsp code