• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

[SQL] varchar2 to number

 
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
 
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
 
Just the other day, I was thinking ... about this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic