How to get non numeric column values from a table?
I need to identify all the non numeric values in a table column. The requirement is as follows.
1. Curently the amount is stored in a VARCHAR2 column ( AMOUNT) of table A.
2. All the data in this table needs to be migrated to new tables. In new tables these columns are having data type of NUMBER.Since the source column is having data type of VARCHAR2 some of values in AMOUNT have non numeric characters. This is causing lot of trouble in migrating the data to a NUMBER field.
Is there any way I can run a SQL to scan the table and identify the records that are having non numeric value in AMOUNT column.
The suggested method will probably recognise the majority of nonnumerical values in your VARCHAR2 column, but it will certanly fail on some strings. For example, it will not find the following few samples to be non-numerical:
etc etc... You get the point.
In fact, I think it would be "very hard" to solve this in generic maner only with SQL and built-in functions. It would be much easier to write your own simple PL/SQL function and use this in your SQL:
create or replace function my_to_number
(p_string in varchar2)
l_number number := null;
l_number := to_number(p_string);
when others then null;
Now you can write your query to extract only those non-numeric values like:
select * from my_table
where my_column is not null
and my_to_number(my_column) is null;
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?