oracle – SQL error ORA-01722: invalid number

oracle – SQL error ORA-01722: invalid number

An ORA-01722 error occurs when an attempt is made to convert a character string into a number, and the string cannot be converted into a number.

Without seeing your table definition, it looks like youre trying to convert the numeric sequence at the end of your values list to a number, and the spaces that delimit it are throwing this error. But based on the information youve given us, it could be happening on any field (other than the first one).

Suppose telephone number is defined as NUMBER then the blanks cannot be converted into a number:

create table telephone_number (tel_number number);
insert into telephone_number values (0419 853 694);

The above gives you a

ORA-01722: invalid number

oracle – SQL error ORA-01722: invalid number

Heres one way to solve it. Remove non-numeric characters then cast it as a number.

cast(regexp_replace(0419 853 694, [^0-9]+, ) as number)

Leave a Reply

Your email address will not be published.