I am unable to create a materialized view and getting a ORA-904 error. This looks like the Bug 17551261 , but this should already be fixed. I tested it on Oracle 12.2, 19 and 21.
In the view i use a connect by statement and ANSI join. When i rewrite the ANSI join to Oracle join the error disappears.
To reproduce the error i created these sample tables:
create table example_type( id number(10) primary key, name varchar2(100 byte));
create table example( id number(10) primary key, name varchar2(100 byte),
father_id number(10) references example(id),
example_type_id number(10) not null references example_type(id) );
With ANSI join:
create materialized view example_list_ansi_join( example_id, root_example_type, example_path)
refresh on demand
as
select e.id example_id,
connect_by_root(et.name) root_example_type,
sys_connect_by_path( e.name, ' > ') example_path
from example e
inner join example_type et on et.id = e.example_type_id
connect by prior e.id = e.father_id
start with father_id is null;
Error:
ORA-12018: following error encountered during code generation for "SQLLIVE"."EXAMPLE_LIST_ANSI_JOIN"
ORA-00904: "from$_subquery$_013"."FATHER_ID_2": invalid identifier
12018.0000 -"following error encountered during code generation for "%s"."%s""
*Cause: The refresh operations for the indicated materialized view could not be regenerated due to errors.
*Action: Correct the problem indicated in the following error messages and repeat the operation.
with Oracle join:
create materialized view example_list_oracle_join( example_id, root_example_type, example_path)
refresh on demand
as
select e.id example_id,
connect_by_root(et.name) root_example_type,
sys_connect_by_path(e.name,' > ') example_path
from example e,
example_type et
where et.id = e.example_type_id
connect by prior e.id = e.father_id
start with e.father_id is null;
No error:
Materialized view EXAMPLE_LIST_ORACLE_JOIN created.
Is this still a bug?