web analytics

How to check Numeric value in Oracle

Reading Time: 1 minute

Currently i could not find any suitable function for checking numeric value on some column. There are many workarounds to achieve this functionality, either cast the column value in Numeric and check, but this can create an exception if not properly coded.

Another workaround for this problem is by using the combination of LENGTH and TRANSLATE function:

LENGTH(TRANSLATE( mystr , ‘0123456789A’ , ‘A’ ))

if above function returns null that means "mystr" contains only numbers , but if it is not null then the field is not numeric.

Leave a Reply

%d bloggers like this: