Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error in converting to To_number

686041Mar 14 2009 — edited Mar 14 2009
i'm using an employee table in which the phone number is stored as a character.. eg: 515.123.4567. i want to extract the last 8 numbers and convert it into a number format..

i user the following query..

select substr(phone_number,-8) from employees

and

select to_number(substr(phone_number,-8),'999.9999')*10000 Local_number from employees -- if i use this it says that ORA-01722 invalid number error..

but the following query

select to_number(substr(phone_number,-8),'999.9999')*10000 local_numbe from employees where department_id<=50 is working properly

but if i gve

select to_number(substr(phone_number,-8),'999.9999')*10000 local_numbe from employees where department_id<=150 --it throwing the same error, though dept 150 is nt thre in my table it should display the lesser, right?


'm using 9i database and in toad i executed these queries

regards renji
This post has been answered by Kamran Agayev A. on Mar 14 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2009
Added on Mar 14 2009
4 comments
659 views