Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Materialized View (Fast Refresh) How to?

Status
Not open for further replies.

cmmrfrds

Programmer
Feb 13, 2000
4,690
0
0
US
I am trying to make a materialized view fast refreshable. It works for inserts on the base table but not for deletes and updates.

Here is the code to create the MV Log.
CREATE MATERIALIZED VIEW LOG ON commerfj.tdl_test
WITH ROWID,
PRIMARY KEY,
SEQUENCE (TX_ID,DETAIL_TYPE,POST_DATE,AMOUNT,PATIENT_AMOUNT,INSURANCE_AMOUNT,ORIGINAL_PAYOR_ID,CUR_PAYOR_ID)
INCLUDING NEW VALUES;

Here is the base table description.
CREATE TABLE COMMERFJ.TDL_TEST
(
TDL_ID NUMBER(16) NOT NULL,
TX_ID NUMBER(38),
POST_DATE DATE,
DETAIL_TYPE NUMBER(38) NOT NULL,
AMOUNT NUMBER(12,2),
PATIENT_AMOUNT NUMBER(12,2),
INSURANCE_AMOUNT NUMBER(12,2),
ORIGINAL_PAYOR_ID NUMBER(38),
CUR_PAYOR_ID NUMBER(38)
)

Here is the MV query.
select
tx_id,
min(rowid) as test_rowid,
min(tdl_id) as tdl_id,
max(case when detail_type = 1 then post_date else null end) as post_date,
sum(amount) as amount,
sum(patient_amount) as patient_amount,
sum(case when detail_type in (20) then amount else 0 end) as payment_amount,
sum(case when detail_type in (21) then amount else 0 end) as adj_amount,
sum(case when detail_type in (1,40,41) then insurance_amount else 0 end) as insurance_amount,
count(amount) as cnt_amt,
count(patient_amount) as cnt_pat,
count(case when detail_type in (20) then amount else 0 end) as cnt_payamt,
count(case when detail_type in (21) then amount else 0 end) as cnt_adj,
count(case when detail_type in (1,40,41) then insurance_amount else 0 end) as cnt_ins,
min(original_payor_id) as original_payor_id,
max(cur_payor_id) as cur_payor_id,
count(*) as cnt
FROM commerfj.tdl_test
group by
tx_id

When I try a delete on the base table, I an error.
ORA-32314: REFRESH FAST of "COMMERFJ"."MV_TDL_TEST" unsupported after deletes/updates.

Can somebody help me get this to work. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top