Skip to main content

IS_NUMERIC

Microsoft SQL Server has a nifty function called IS_NUMERIC which will return a Boolean if the parameter passed is a numeric value.

It's long been lamented that Oracle has no similar function..but it's all just a lie. While technically true that Oracle does not have an IS_NUMERIC function, it does have support for regular expressions.

Oracle released regular expressions in 10g, which seems like eons ago.

The following regular expression can be added to an SQL script in Oracle to test for a numeric value:

REGEXP_LIKE (col1,'^[[:digit:]]+$');

where col1 is the column you wish to test.

select * from tab1 where REGEXP_LIKE (col1,'^[[:digit:]]+$');

will return all the rows in table TAB1 where COL1 matches the test from the regular expression.



Comments