6

I have couple of columns in Oracle Table.

EMP_SEQ_NO  Number(5)
Some_COL    Varchar(20)

EMP_SEQ_NO    Some_COL
10             ABCD
11              11
12             Test
13             Tommy
14              14
15              15
16              Ronny

I am trying to do something like

Select * from EMP where EMP_SEQ_NO=Some_COL

It is throwing Invalid number error.

Please help

3 Answers 3

5

Using to_char solves your problem.

Select * from EMP where to_char(EMP_SEQ_NO)= to_char(Some_COL)
Sign up to request clarification or add additional context in comments.

Comments

0

Both of them are of different types. So, you should cast one of them to the type of the other:

Select * from EMP 
where CAST(EMP_SEQ_NO as varchar(20)) = Some_COL

OR

Select * from EMP 
where EMP_SEQ_NO = CAST(Some_COL as number(5))

Comments

0

to_number will solve this

Select * from EMP where EMP_SEQ_NO= to_number(Some_COL, '99999');

1 Comment

Really? select to_number('ABCD', '99999') from dual; gives me ORA-01722: invalid number

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.