Wednesday, May 28, 2014

SELECT ORACLE VARCHAR2 FILTER DIGITS NUMERIC NUMBER VALUES

if you have column in your table contains varchar2 values and need to check for digit values
or set constraint to enforce inserted data to be integer digits not special characters or alphabetic characters you can use this sample query to create your constraint.

SELECT COUNT(*) FROM yourschema.yourtable
WHERE
REGEXP_LIKE(columnName,'[[:digit:]]')


-----------------------------------------------------------------------------------------
to check Digit with specific length you can use this sample
ex : get data with 9 characters digit values

SELECT * FROM xx
WHERE
REGEXP_LIKE(columnName, '^[[:digit:]]{9}$')

-------------------------------------------------------------------------------------
to check for digits and characters with specific length you can use this template
ex: the query will select data contains 4 alpha chars and 3 digits.
SELECT * FROM xx
WHERE


REGEXP_LIKE(SEGIL_NO, '[[:alpha:]]{4}[[:digit:]]{3}')

[[:alpha:]]{4}[[:digit:]]{3}

No comments:

Post a Comment