Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Materialized Views w Refresh Fast on Commit

Posted on 2004-10-04
8
Medium Priority
?
1,557 Views
Last Modified: 2008-01-16
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???
0
Comment
Question by:MrNed
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 1000 total points
ID: 12223710
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
 
LVL 6

Expert Comment

by:morphman
ID: 12224263
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
 
LVL 7

Author Comment

by:MrNed
ID: 12224384
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:morphman
ID: 12224389
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
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12224474
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
 
LVL 7

Author Comment

by:MrNed
ID: 12233470
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
 
LVL 11

Expert Comment

by:cjjclifford
ID: 12235443
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
 
LVL 7

Author Comment

by:MrNed
ID: 12337266
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question