Of course the best approach is a UDF.
If oTranslate is installed this is an old trick to get rid of any unwanted chars:
oTranslate(a, '.' || oTranslate(a, '.0123456789', '.'), '.')
When your version of oTranslate is not considering empty strings as NULL (stupid Oracle) it's easier:
oTranslate(a, oTranslate(a, '0123456789', ''), '')
Without UDFs you could avoid recursion, too:
case when substring(a from 1 for 1) between '0' and '9' then substring(a from 1 for 1) else '' end ||
case when substring(a from 2 for 1) between '0' and '9' then substring(a from 2 for 1) else '' end ||
case when substring(a from 3 for 1) between '0' and '9' then substring(a from 3 for 1) else '' end ||
...
Of course this assumes column a has a short length.
Dieter
↧