Materialized Views w Refresh Fast on Commit

Hi all,

I am using Oracle 9.2.0.5 and want to create a mat view with simple joins between three tables. When I try:

create materialized view test1
refresh fast on commit
as
SELECT a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns

It says "ORA-12052: cannot fast refresh materialized view TEST1"

I have created mat view logs on the base tables and after some research I found that:

"Rowids of all the tables in the FROM list must appear in the SELECT list of the query. " - From the Oracle doco

so i tried:

create materialized view test1
refresh fast on commit
as
SELECT a.rowid, b.rowid, c.rowid, a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns

but now it gives me "ORA-00904: "ROWID": invalid identifier"

How can I get this working???
LVL 7
MrNedAsked:
Who is Participating?
 
jdlambert1Connect With a Mentor Commented:
If your statement were to work, and you submitted "SELECT rowid, col1 FROM test1" which column would it report for rowid? It'd have three to choose from. Same with Col1. You just need to give them aliases:

create materialized view test1
refresh fast on commit
as
SELECT a.rowid as rowidA, b.rowid as rowidB, c.rowid as rowidC, a.col1, b.col1, c.col1
from table1 a, table2 b, table3 c
where a.columns = b.columns
and b.columns = c.columns
0
 
morphmanCommented:
make sure your materialized view log has been created with rowid

create materialized view log on table1 with rowid(col1);
create materialized view log on table2 with rowid(col1);
create materialized view log on table3 with rowid(col1);
0
 
MrNedAuthor Commented:
Thanks jdlambert1 - it was staring at me in the face!

Morphman - yes i have.

To do with the same issue, can anyone tell me why i get the error "ORA-12053: this is not a valid nested materialized view" when trying to create another mat view of the one above?

create materialized view test2
refresh fast on commit
as
select col1, col2, col3, min(col4)
from test1
group by  col1, col2, col3

Even removing the min(col4) gives the same error.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
morphmanCommented:
You cannot use MIN with fast refresh. Its one of the limitations. You cannot use MAX either.

Not sure why you get the error if you remove min(col4) though.
0
 
cjjcliffordCommented:
removing min(col4) still leaves implicit aggregation, done by the "group by".
If you remove min(col4) and the "group by" then the second one should be ok, although not very useful (will contain the same as the "test1" Mview.
0
 
MrNedAuthor Commented:
i was able to create a mat view with a group by on a normal table - so its a limitation that it cant do that with mat views instead of a normal table?
0
 
cjjcliffordCommented:
Sorry, I was thinking the "group by" was intruducing an implicit aggregation function, which is not allowed for fast refresh views... when you tested with normal table did you use fast refresh? If so, you've got me stumpped why it works on table and not on mview...

Cheers,
C.
0
 
MrNedAuthor Commented:
Yes i used fast refresh for the normal table. I still havent found out a solution for this, but have used triggers to maintain a normal table instead.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.