I need to check if a string contains a number. Any number. Not wether or not the string IS a number, but if it contains one.
Examples:
\'test\' = no numbers.
This is the technique that I use to detect if a string contains a number:
select LAST_NAME, 'contains a number'
FROM names
where translate(LAST_NAME, '0123456789', '') <> LAST_NAME
That works by translating the digits to empty string. If the string remains the same, then it could not have contained digits.
This technique also works to test if a string is all numbers
select TEL_NUMBER, 'is all numbers'
FROM names
where trim(translate(TEL_NUMBER, '-0123456789', '')) = ''
For the telephone number I included a dash because telephone numbers typically contain dashes.