Total Pageviews

2013/04/15

Test a string for a numeric value


Environment 
Oracle 11g

Problem

I write wrong value into specific column, it should accept numeric only.


Solution

To test a string for numeric characters, you could use a combination of the length function, trim function, and translate function built into Oracle.

You can use the following command:




This function will return a null value if vio_yr is numeric. It will return a value "greater than 0" if vio_yr contains any non-numeric characters.


Reference: http://www.techonthenet.com/oracle/questions/isnumeric.php

No comments: