More Oracle regexp_like

Two more examples of regexp_like for the memory banks:


-- convert to NULL if SOME_COL is not A,B,C,1,2,or 3
case
when (regexp_like(a.SOME_COL,'[^A-C1-3]'))
then NULL
else
a.SOME_COL
end as SOME_COL,

-- convert to 0000 if the col's value is not a series of valid digits
case
when (regexp_like (a.ANOTHER_COL,'[^[:digit:]]'))
then '0000'
else
a.ANOTHER_COL
end as ANOTHER_COL,

This entry was posted in oracle/sqlserver/database. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *