If you could have a NOT NULL constraint in the view column, I believe that the SELECT from the view will then fail if the column in question was NULL. If this is the intention, then the following may give you what you are looking for:
CREATE OR REPLACE VIEW some_view AS SELECT some_field, some_other_field, CASE WHEN field_of_interest IS NOT NULL THEN CAST(field_of_interest AS BINARY_DOUBLE) ELSE 1 / 0 END AS field_of_interest_not_null FROM some_table;
Not very attractive, and you get the ugly message "ORA-01476: division is zero" if the ELSE CASE branch is selected, but perhaps this is a step on the road to "better."
Share and enjoy.
EDIT: If the goal is to only collect rows where your target column is not null, perhaps you could add a WHERE clause to your view, as in:
CREATE OR REPLACE VIEW some_view AS SELECT some_field, some_other_field, CAST(field_of_interest AS BINARY_DOUBLE) AS field_of_interest FROM some_table WHERE field_of_interest IS NOT NULL;
YMMV.
EDIT2: Looking at the SQL Server example, it seems that the ISNULL function is used to ensure that the column is never NULL. If this is acceptable, you can do the following:
CREATE OR REPLACE VIEW some_view AS SELECT some_field, some_other_field, CAST(NVL(field_of_interest, 0.0) AS BINARY_DOUBLE) AS field_of_interest FROM some_table WHERE field_of_interest IS NOT NULL;
To quote Bullwinkle: βThis time sure!β :-)
Bob jarvis
source share