views:

2650

answers:

3

How do i convert a oracle varchar value to number

eg

table - exception
exception_value 555 where exception_value is a varchar type

I would like to test the value of exception_value column

select * from exception where exception_value = 105 instead of
select * from exception where exception_value = '105'
+1  A: 

select to_number(exception_value) from exception where to_number(exception_value) = 105

dpbradley
+1  A: 

You have to use the TO_NUMBER function:

select * from exception where exception_value = to_number('105')
FerranB
+2  A: 

Since the column is of type VARCHAR, you should convert the input parameter to a string rather than converting the column value to a number:

select * from exception where exception_value = to_char(105);
Tony Andrews