Swaminathan K
asked on
oracle numeric condition check
Hi Team,
I have an requirement , where in I need to check whether the numeric fields in the table are having numeric values or not. If not then I need to update the status to E which means error.
Here again what is the best solution , the reason being if I use the
Select to_number(internal_key,'99 99999999') from dual , if the internal_key column has character value then it will throw an error and
will not be able to update the table.
table name
test_data
employeeID NUMBER
internal_KEY VARCHAR2(10)
band_ID VARCHAR2(38)
appraisal_score DECIMAL(2,5)
salary VARCHAR2(10)
STATUS CHAR(1)
ERROR_CODE VARCHAR2(15)
ERROR_DESC VARCHAR2(1000)
I have an requirement , where in I need to check whether the numeric fields in the table are having numeric values or not. If not then I need to update the status to E which means error.
Here again what is the best solution , the reason being if I use the
Select to_number(internal_key,'99
will not be able to update the table.
table name
test_data
employeeID NUMBER
internal_KEY VARCHAR2(10)
band_ID VARCHAR2(38)
appraisal_score DECIMAL(2,5)
salary VARCHAR2(10)
STATUS CHAR(1)
ERROR_CODE VARCHAR2(15)
ERROR_DESC VARCHAR2(1000)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Expanding a bit on slightwv's solution -
update test_table
set status = 'E'
where regexp_instr(internal_key, '^[0-9]+$' ) = 0
update test_table
set status = 'E'
where regexp_instr(internal_key,
ASKER