I need to create an Oracle DB function that takes a string as parameter. The string contains letters and numbers. I need to extract all the numbers from this string. For example, if I have a string like RO1234, I need to be able to use a function, say extract_number('RO1234'), and the result would be 1234.
To be even more precise, this is the kind of SQL query which this function would be used in.
SELECT DISTINCT column_name, extract_number(column_name)
FROM table_name
WHERE extract_number(column_name) = 1234;
QUESTION: How do I add a function like that to my Oracle database, in order to be able to use it like in the example above, using any of Oracle SQL Developer or SQLTools client applications?
regex_replace,SELECT REGEXP_REPLACE(column_name,'[[:alpha:]]') from tbl, at least you should search in Google, see this(community.oracle.com/thread/598281) oracle community provides some usefull waystable_name(and possibly also incorrectly aroundcolumn_name). Also why would you want to have the extracted number also in the column list, when you already know exactly what it is, as you have specified it in theWHEREcondition?