Is there any way to create a derived column based on the result of an expression in 10g?
Specifically, I have inherited a table which contains both character data and numeric data within a varchar2 field. Obviously, that causes no end of headaches when trying to do joins, as I constantly get “invalid number” errors when Oracle reorders my query which utilizes to_number() on the field. So, what I’d like to do is create a derived column which has a value if the original column’s value is numeric and NULL if it is not and use that in the join rather than the field with mixed types.
Note that I’m attempting to do this in a query, not in a procedure/function.
Is such a thing possible?
The closest you can come in 10g is a function-based index. Something like
This generally requires that a function be created and referenced in your query but the function-based index pre-computes the result so you’re not actually calling the function at run-time. If you really want to avoid the function, you could create the index on a
CASEstatement as well and then reference that sameCASEstatement in your query but that would seem to complicate the situation, not make it simpler.