Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[SQL] varchar2 to number

 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Michael Houlo
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had to use
to_number(field,'99.999999999','NLS_NUMERIC_CHARACTERS=''. ''')
together with a TRIM..

Thanks anyway
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic