I'm getting ORA-01722: invalid number but only when I select * from theView but not when I select against the theView directly (using the SQL inside the view's CREATE OR REPLACE...).
(I have faced and understand this error before, as well as running aggregates against NULL values, that one shouldn't store VARCHARS in NUMBER columns, etc. but am struggling to understand this issue)
Usually you get it when oracle executes your filter predicate that should filter only numbers, after predicates where you use it as a number.
Simple example:
You can see we get ORA-01722 in this very simple example even though we specified filter
xtype='num'beforex > 0:Execution plan:
As you can see from the plan, inline view was
mergedand both predicates are on the same level.Now compare with this:
Execution plan:
Read more about this: http://orasql.org/2013/06/10/too-many-function-executions/