Create materialized view
can i create a materialized view
with joins, group by and aggregate all these things on a single materialized view if yes then how ??
please use scott schema or hr as i am new to oracle
thks and regards
Hi,
Hope it'll help you:
create table EMPLOYEE (id number(10), first_name varchar2(20), last_name varchar2(20));
insert into EMPLOYEE values (1, 'John', 'White');
insert into EMPLOYEE values (2, 'Maggie', 'Black');
insert into EMPLOYEE values (3, 'George', 'Red');
insert into EMPLOYEE values (4, 'Linda', 'Green');
commit;
create table SALARY(id number(10), emp_id number(10), payment_date date, amount number(10,2));
insert into SALARY values(1, 1, '01-Jan-2010', 10.00);
insert into SALARY values(2, 3, '03-Jan-2010', 30.00);
insert into SALARY values(3, 4, '02-Jan-2010', 50.00);
insert into SALARY values(4, 2, '02-Jan-2010', 150.00);
insert into SALARY values(5, 3, '02-Feb-2010', 2150.00);
insert into SALARY values(6, 1, '05-Feb-2010', 7402.00);
insert into SALARY values(7, 4, '10-Feb-2010', 9990.00);
insert into SALARY values(8, 1, '15-Feb-2010', 19990.00);
commit;
create materialized view SAL_REPORT
as
select emp.first_name,
emp.last_name,
to_char(sal.payment_date, 'YYYYMM') Year_Month,
sum(sal.amount) Amount
from EMPLOYEE emp
left outer join SALARY sal on emp.id = sal.emp_id
group by emp.first_name,
emp.last_name,
to_char(sal.payment_date, 'YYYYMM')
order by 4, 1, 2, 3;
select * from SAL_REPORT;Good luck!
http://dba-star.blogspot.com/
Similar Messages
-
Creating Materialized View in Toad
As with every new endeavor - come new questions.
I am trying to create a materialized view via toad (first time doing this). Now - toad is great, since it provides a kind-of wizard interface. Hence, one doesn't have to completely code in the create statement, with all of the options, etc.
Instead, in toad, one can (via the schema browser), go into the Materialized Views tab and click on create new. This opens a window with 6 tabs: Basic Info, Refresh Info, Physical Attributes, Query, Partitions & Subpartition Template.
In the Basic Info, one can put a check mark next to some of the following options:
-Build Deffered
-Parallel
-Cache
-Logging
-Using index
-Allow updates
etc.
I have read that build deferred refers to whether or not you would like the view to be created automatically or to be deferred.
Anyways, I tried to find Toad documentation to explain each of the options in-detail. No success. Hence, am researching each part piece by piece.
But - here is my question:
In the Query tab, we are asked to specify a query. I am assuming that the query does not have to be a full query, beginning with CREATE MATERIALIZED VIEW mv_table1 REFRESH FAST etc...
Since in this 'wizard', we are providing the MV name at the top of the dialog box, we are checking the 'options' in the other tabs, etc.
And so, I assumed that the query should merely be a select query in the window mentioned above.
So I entered the following:
select * from table1@remote_db;
When I go to verify the syntax, I get the error message: ORA_00911: invalid character. It seems to be pointing to my db_link (remote_db). I have been using this link throughout many places, w/o any problems.
Has anyone created a MV in toad before? Any links to good toad documentation would be helpful as well.
Thanks.(This is fun... ;))
For anyone endeavoring this in the future, below I have attached the prerequisites required in order to create a materialized view (can also be found @ http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm):
Prerequisites
The privileges required to create a materialized view should be granted directly rather than through a role.
To create a materialized view in your own schema:
You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
To create a materialized view in another user's schema:
You must have the CREATE ANY MATERIALIZED VIEW system privilege.
The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.
To create the materialized view with query rewrite enabled, in addition to the preceding privileges:
If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.
The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.
When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects. -
Error while creating materialized view which using database link
Helo!
I'm getting error "ORA-00942: table or view does not exist" when I want to create materialized view.
Details:
1. On destination database I create a database link:
CREATE DATABASE LINK SDATABASE
CONNECT TO MYUSER
IDENTIFIED BY MYUSERPASS
USING 'ORCL';
=> Command "SELECT * FROM TABLE1@SDATABASE" returns data normally!
2. On source database I create MATERIALIZED VIEW LOG:
CREATE MATERIALIZED VIEW LOG
ON TABLE1
WITH PRIMARY KEY
INCLUDING NEW VALUES;
3. Now, when I want to create MATERIALIZED VIEW on destination database:
CREATE MATERIALIZED VIEW TABLE1
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE + 1/1440
WITH PRIMARY KEY
AS SELECT * FROM TABLE1@SDATABASE;
...I get error "ORA-00942: table or view does not exist"!
How is that possible if command "SELECT * FROM TABLE1@SDATABASE" returns data normally?
Thanks,
VorancAnd, I'm using Oracle 10g.
Voranc -
How to create materialized view based on a view?
Hi,
I hope this is not very far fetched idea.
I have a very complex view and I would like to replicate it 'in place' that is I would like to make a materialized view that is based on this view complex view. I would like to use this materialized view (i.e table) to query data instead of using the original view, since it takes Oracle some 10-15 seconds to execute my query on the original view and I am not allowed to create indexes on most of the tables that are included in the original view.
Can this be done?
Best regards,
Tamas SzecsyThe best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
select text
from user_views
where view_name = 'NAME_OF_VIEW'
You can then cut and paste the sql statement into your create materialized view statement.
Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
SQL> set long 2048 -
How to create materialized view based on a synonym
Hi all,
I am trying to create simple materialized view based on a synonym and that synonym is pointing a view in other database (using dblink). I am getting table or view not found error . I am able to select synonym if i use select but not in materialized view. Please help me.
Thanks,The best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
select text
from user_views
where view_name = 'NAME_OF_VIEW'
You can then cut and paste the sql statement into your create materialized view statement.
Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
SQL> set long 2048 -
How to CREATE MATERIALIZED VIEW LOG (MV fast refresh) with some JOINS
Hi @ all,
i'm trying to create a MATERIALIZED VIEW LOG for a fast refresh of a MATERIALIZED VIEW.
It works fine with a simple Request in the MATERIALIZED VIEW:
CREATE MATERIALIZED VIEW MV_ZOTD43_P
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT * FROM ZOTD43_P;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON ZOTD43_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_ZOTD43_P', 'f');
But when I use a complex SQL-Request with some JOINS (one of the Table with spatial Data) in the MATERIALIZED VIEW, I get an error:
CREATE MATERIALIZED VIEW MV_TEST
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT lptd04_p.sst_nr AS sst_nr,
lptd03_p.aaaa AS aaaa,
lptd04_geom.geom as geom
FROM lptd04_p lptd04_p
JOIN lptd01_p lptd01_p ON lptd01_p.cre_nr = lptd04_p.sst_nr
JOIN lptd04_geom ON lptd04_geom.sst_nr = lptd04_p.sst_nr
JOIN lptd03_p lptd03_p ON lptd03_p.lief_nr = lptd04_p.lief_nr;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON LPTD04_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_TEST', 'f');
Error report:
SQL Error: ORA-12004: REFRESH FAST kann für Materialized View "GDI"."MV_GDI_SST_STAMM" nicht benutzt werden
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2255
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2461
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2430
ORA-06512: in Zeile 1
12004. 00000 - "REFRESH FAST cannot be used for materialized view \"%s\".\"%s\""
*Cause: The materialized view log does not exist or cannot be used. PCT
refresh is also not enabled on the materialized view
*Action: Use just REFRESH, which will reinstantiate the entire table.
If a materialized view log exists and the form of the materialized
view allows the use of a materialized view log or PCT refresh is
possible after a given set of changes, REFRESH FAST will
be available starting the next time the materialized view is
refreshed.
Am I doing something wrong or is it not possible CREATE MATERIALIZED VIEW LOG when the MATERIALIZED VIEW got some JOINS?
Regards,
GreqThanks for the link Alessandro ,
the error seems something to do with the Column-Type SDO_GEOMETRY, so
i create a new thread in the Spatial Discussion forum:
FAST REFRESHing of Oracle Materialized Views containing SDO_GEOMETRY column
Regards,
Greq -
Can we create materialized view on the top of another materialized view.
Hi ,
can we create materialized view on the top of another materialized view.
Thanks
NaveenWelcome , Just remember is not good apporch to do that since performance when MV refresh
Please mark this thread as answered . -
Error While Creating Materialized View
Hello,
I am getting error ORA-22818: subquery expressions not allowed here while creating materialized view. I am using Oracle9i Enterprise Edition Release 9.2.0.1.0. Below pasted is my SQL Script.
Any help is highly appreciable.
Thanks
*********SQL************
select distinct(id),NAME,(select count(GRADE) from employees where
nationality like '%US%'and id=a.organization_id and grade=a.grade
group by ID,GRADE) US,(select count(GRADE) from employees where
nationality not like '%US%' and organization_id=a.organization_id and grade=a.grade
group by ORGANIZATION_ID,GRADE) NON_US,grade from employees a
where grade is not null
group by GRADE,ID,name
order by to_number(grade) descHi,
This is a documented restriction on MVs. You cannot have a scalar express (i.e a select statement) in the select list.
You can get round this by joining your select count(grade).. expression in as an inline view in your FROM clause. Or you can create a normal view without the scalar expression, create your MV as a select from this view, then re-define your view to contain the query you want.
Hope that helps,
Rod West -
Error occured while creating MATERIALIZED VIEW
I created as below:
CREATE MATERIALIZED VIEW LOG ON FIN.F_CV_HDR
WITH ROWID, SEQUENCE, PRIMARY KEY;
CREATE MATERIALIZED VIEW LOG ON FIN.F_CV_DTL
WITH ROWID, SEQUENCE;
REATE MATERIALIZED VIEW F_GL_SMRY_MVW
PARALLEL
BUILD IMMEDIATE
REFRESH FAST ON COMMIT AS
SELECT * FROM
SELECT
F_CV_HDR.ROWID "HDR_ID",
CAST(NULL AS ROWID) "DTL_ID",
cah_dsm_trm_tr_code gsv_dsm_trm_tr_code,
cah_dsm_dcmnt_type gsv_dsm_dcmnt_type,
cah_cv_nmbr gsv_dcmnt_nmbr,
cah_lcm_lctn_code dsv_lcm_lctn_code,
cah_dsm_dcmnt_srs gsv_dsm_dcmnt_srs,
cah_cv_date gsv_dcmnt_date,
'G' gsv_sub_code_type,
DECODE(cah_dsm_dcmnt_type,'CPV',0,'CRV',cah_net_amnt) gsv_amnt_dbtd,
DECODE(cah_dsm_dcmnt_type,'CPV','C','CRV','D') gsv_dr_cr_indctr,
cah_net_amnt gsv_amnt,
DECODE(cah_dsm_dcmnt_type,'CPV',cah_net_amnt,'CRV',0) gsv_amnt_crdtd,
cah_asm_sbldgr_code gsv_sub_code,
CAH_RMRKS GSV_RMRKS,
CAST(NULL AS VARCHAR2(3)) GSV_CRS_RFRNCE_TYPE,
CAST(NULL AS VARCHAR2(3)) GSV_CRS_RFRNCE_TR_CODE,
CAST(NULL AS NUMBER(10)) GSV_CRS_RFRNCE_NMBR,
CAST(NULL AS VARCHAR2(6)) GSV_FCM_CRNCY_CODE,
CAST(NULL AS NUMBER(6,3)) GSV_EXCHNGE_RATE,
CAST(NULL AS NUMBER(13,2)) GSV_FRGN_CRNCY_AMNT,
CAST(NULL AS DATE) GSV_DATE_FROM,
CAST(NULL AS DATE) GSV_DATE_TO,
CAST(NULL AS NUMBER(7)) GSV_RJH_NMBR,
CAST(NULL AS VARCHAR2(3)) GSV_PJC_SRS,
CAST(NULL AS NUMBER(7)) GSV_PJC_NMBR,
CAST(NULL AS NUMBER(3)) GSV_PJC_EQPTMNT_SRL,
CAST(NULL AS VARCHAR2(5))GSV_PJC_EXPNSE_HEAD_CODE,
CAST(NULL AS VARCHAR2(3)) gsv_dpm_dprtmnt_code,
cah_asm_amm_main_code gsv_amm_main_code,
CAH_LCM_LCTN_CODE_BOOK GSV_LCM_LCTN_CODE_BOOK,
CAST(NULL AS NUMBER) gsv_dr_cr_advce_srl,
0 gsv_dcmnt_srl_nmbr,
cah_trnsctn_with_indctr gsv_trnsctn_with_indctr,
cah_trnsctnr_code gsv_trnsctnr_code,
0 gsv_net_tds_amnt,
to_number(TO_CHAR(cah_cv_date ,'YYYY')) gsv_year,
to_number(TO_CHAR(cah_cv_date ,'MM')) gsv_mnth,
cah_cv_tmpry_nmbr gsv_tmpry_nmbr,
CAH_SRCE_INDCTR GSV_SRCE_INDCTR,
CAST(NULL AS VARCHAR2(50)) GSV_BILL_NMBR,
CAST(NULL AS DATE) gsv_bill_date,
cah_pay_rcve_name gsv_pay_rcve_name
FROM f_cv_hdr
WHERE CAH_FNCL_CLSRE_INDCTR = 'N'
AND cah_avlble_indctr = 'Y'
UNION ALL
SELECT
F_CV_HDR.ROWID "HDR_ID",
f_cv_dtl.ROWID "DTL_ID",
cah_dsm_trm_tr_code gsv_dsm_trm_tr_code,
cah_dsm_dcmnt_type gsv_dsm_dcmnt_type,
cah_cv_nmbr gsv_dcmnt_nmbr,
cah_lcm_lctn_code dsv_lcm_lctn_code,
cah_dsm_dcmnt_srs gsv_dsm_dcmnt_srs,
cah_cv_date gsv_dcmnt_date,
cad_sub_code_type gsv_sub_code_type,
DECODE(cad_dr_cr_indctr, 'C',0,'D',cad_amnt) gsv_amnt_dbtd,
cad_dr_cr_indctr gsv_dr_cr_indctr,
cad_amnt gsv_amnt,
DECODE(cad_dr_cr_indctr, 'D',0,'C',cad_amnt) gsv_amnt_crdtd,
cad_sub_code gsv_sub_code,
cad_rmrks gsv_rmrks,
cad_crs_rfrnce_type gsv_crs_rfrnce_type,
cad_crs_rfrnce_tr_code gsv_crs_rfrnce_tr_code,
CAD_CRS_RFRNCE_NMBR GSV_CRS_RFRNCE_NMBR,
CAST(NULL AS VARCHAR2(6)) GSV_FCM_CRNCY_CODE,
CAST(NULL AS NUMBER(6,3)) GSV_EXCHNGE_RATE,
CAST(NULL AS NUMBER(13,2)) gsv_frgn_crncy_amnt,
cad_date_from gsv_date_from,
cad_date_to gsv_date_to,
cad_rjh_nmbr gsv_rjh_nmbr,
cad_pjc_srs gsv_pjc_srs,
cad_pjc_nmbr gsv_pjc_nmbr,
cad_pjc_eqpmnt_srl gsv_pjc_eqptmnt_srl,
cad_pjc_expnse_head_code gsv_pjc_expnse_head_code,
cad_dpm_dprtmnt_code gsv_dpm_dprtmnt_code,
cad_amm_main_code gsv_amm_main_code,
cah_lcm_lctn_code_book gsv_lcm_lctn_code_book,
cad_dr_cr_advce_srl gsv_dr_cr_advce_srl,
cad_cv_srl_nmbr gsv_dcmnt_srl_nmbr,
cah_trnsctn_with_indctr gsv_trnsctn_with_indctr,
cah_trnsctnr_code gsv_trnsctnr_code,
0 gsv_net_tds_amnt,
to_number(TO_CHAR(cah_cv_date ,'YYYY')) gsv_year,
to_number(TO_CHAR(cah_cv_date ,'MM')) gsv_mnth,
cah_cv_tmpry_nmbr gsv_tmpry_nmbr,
cah_srce_indctr gsv_srce_indctr,
CAST(NULL AS VARCHAR2(50)) GSV_BILL_NMBR,
CAST(NULL AS DATE) GSV_BILL_DATE,
cah_pay_rcve_name gsv_pay_rcve_name
FROM f_cv_hdr,
F_CV_DTL
WHERE CAH_FNCL_CLSRE_INDCTR = 'N'
AND cah_avlble_indctr = 'Y'
AND cah_lcm_lctn_code = cad_cah_lcm_lctn_code
AND CAH_DSM_DCMNT_TYPE = CAD_CAH_DSM_DCMNT_TYPE
AND cah_cv_tmpry_nmbr = cad_cah_cv_tmpry_nmbr);
Giving below error:
==================================================
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
12054. 00000 - "cannot set the ON COMMIT refresh attribute for the materialized view"
*Cause: The materialized view did not satisfy conditions for refresh at
commit time.
*Action: Specify only valid options.
==================================================*Action: Specify only valid options.
-
Error while creating Materialized View step 3 of 6 using wizard
have oracle 9i Rel 1 on Windows 2000 server. Master Site has been setup. Database links are created at Materialized view site. But while creating Materialized View Group using wizard there is following error on step 3 of 6.
Statement:----------------
/*OracleOEM*/ SELECT 1 FROM SYS.dba_constraints@masterdbname WHERE OWNER='username' and table_name='tabname' AND constraint_type='P'
Stack Trace:----------------
ORA-00942: table or view does not exist.
ORA-02063: preceding line from masterdbname.
All parameters for replication are correct.
Please help me early.
ThanksHello,
In the masterdbname, logging as sys user, you must grant select permission on sys.dba_constraints view to mvadmin_dbname user (where dbname is the replicated database name).
Regards, -
Error while creating Materialized View step 3 of 6
I have oracle 9i Rel 1 on Windows 2000 server. Master Site has been setup. Database links are created at Materialized view site. But while creating Materialized View Group there is following error on step 3 of 6.
Statement:----------------
/*OracleOEM*/ SELECT 1 FROM SYS.dba_constraints@masterdbname WHERE OWNER='username' and table_name='tabname' AND constraint_type='P'
Stack Trace:----------------
ORA-00942: table or view does not exist.
ORA-02063: preceding line from masterdbname.
All parameters for replication are correct.
Please help me early.
ThanksHello,
In the masterdbname, logging as sys user, you must grant select permission on sys.dba_constraints view to mvadmin_dbname user (where dbname is the replicated database name).
Regards, -
Error in creating materialized view
Hi all,
I am trying to create the following materialized view, but throwing me the error message below
CREATE MATERIALIZED VIEW "MVIW"."XXFA_R051_SHT2_AMV"
(PARTITION BY LIST (PERIOD_YEAR)
PARTITION YEAR2006 VALUES LESS ('2006'),
PARTITION YEAR2007 VALUES LESS ('2007'),
PARTITION YEAR2007 VALUES LESS ('2008'))
TABLESPACE "MVIEW"
BUILD IMMEDIATE
USING INDEX
REFRESH FORCE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS (SELECT * FROM XXFA_R051_SHT2_MV);
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Any pointers would be appreciated
Thanks
VRWhat is it your are actually trying to do?
On one hand you say:
PARTITION BY LIST (PERIOD_YEAR)
Then you proceed to use the syntax for range partitioning:
VALUES LESS ('2006'),
Look up the correct syntax at http://tahiti.oracle.com or the demos in Morgan's Library at www.psoug.org. -
Error on creating Materialized view.
Hi,
I don't understand why it happens...
When I tried to creating materialized view, it shows a error "ORA-01013: User requested cancel of current operation".
I don't understand why it happens. I just waited it successfully created. But I didn't press any button.
Does it matter of size of joining table? I had same issue before. At that time I just removed some tables from the joining condition, this error was gone.
But at this time, I cannot exclude any other tables the select statement
Can anyone help me this issue, please?Hi,
11g ( 11.2.0.3 ) has a problem with materialized views based on ROWID, resulting in the problem you mentioned.
A workaround is creating the MV's based on primary keyl.
There is also a patch available on MOS, to solve the problem ( thanks to a very long SR from me :-) )
It is known as bug 13657605 and the patch for it has the same number.
Remember to read the README, as this patch is only for 11.2.0.3 !!
Cheers
FJFranken -
Error while creating Materialized View in AWM
Hello,
I am using Oracle 11g with Analytic WorkSpace Manager 11.1.0.6.0A
I am trying to create materialized view on my Cube..
The Cube has 5 Dimensions out of which Four are having two levels i.e.,
TotalA-->DimensionA
TotalB-->DimensionB...and so on
And one time Dimension having 4 levels
TotalTime-->YEAR-->QUARTER-->MONTH
When i try to create the materialized view, i get an error saying that
"Your metadata changes have been saved, with the following errors
CREATE MATERIALIZED VIEW "ENT.CB$TIME_TIME_HIER"
ORA-02267:column type incompatible with referenced column type"
When i googled regarding this error, it says to change the datatype of the column..
But which column's data type is to be changed..Please throw some light regarding this...
Awaiting for reply..My query is as follows:
SELECT
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_Type1Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Type2Txn_Amount,
sum(cd.SALESAMT *(case when (k.LONG_DESCRIPTION='product1'AND l.level_name='ALL_MODE'AND m.LONG_DESCRIPTION = 'Type1' )then 1 else 0 end)) as Cumm_product1_Type1Txn_Amount,
sum(cd.SALESAMT *(case when (k.LONG_DESCRIPTION='product1'AND l.level_name='ALL_MODE'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_product1_Type2Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode1'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_Mode1_Type1Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode1'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode1_Type2Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode2'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_CLRING_Type1Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode2'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode2_Type2Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode3'AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_TRSFER_Type1Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.LONG_DESCRIPTION='Mode3'AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_Mode3_Type2Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.level_name='ALL_MODE' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.long_description='Mode3' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Mode3_Txn_Amount,
sum(cd.SALESAMT *(case when (k.LEVEL_NAME = 'ALL_product' AND l.long_description='Mode2' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_Mode2_Txn_Amount,
sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.level_name='ALL_MODE' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_product1_Txn_Amount,
sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.LONG_DESCRIPTION = 'Type1')then 1 else 0 end)) as Cumm_product1Mode1Type1_Txn_Amount,
sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.LONG_DESCRIPTION = 'Type2')then 1 else 0 end)) as Cumm_product1_Mode1_Type2_Txn_Amount,
sum(cd.SALESAMT *(case when (k.long_description = 'product1' AND l.long_description='Mode1' AND m.level_name = 'ALL_TYPE')then 1 else 0 end)) as Cumm_product1_Mode1_Total_Txn_Amount
/* From dimension views and cube view */
FROM CUSTOMER_ID_CUSTOMER_ID_HIE_VIEW b,
TIME_TIME_HIER_VIEW j,
product_product_HIER_VIEW k,
MODE_MODE_HIER_VIEW l,
TYPE_TYPE_HIER_VIEW m,
CUBETEST_VIEW cd
/* Create level filters */
WHERE b.level_name = 'CUSTOMER_ID'
AND b.LONG_DESCRIPTION='xyz'
AND j.LEVEL_NAME='MONTH'
AND j.END_DATE between to_date('2007-10-31','YYYY-MM-DD') and to_date('2007-10-31','YYYY-MM-DD')
/* Join dimension views to cube view */
AND b.DIM_KEY=cd.ACCOUNT_ID
AND j.DIM_KEY=cd.TIME
AND k.DIM_KEY=cd.product
AND l.DIM_KEY=cd.MODE
AND m.DIM_KEY=cd.TYPE
ORDER BY j.end_date,
k.level_name,
l.level_name,
m.level_name; -
Problems in creating Materialized View from 10g R2 to 11g
Hi,
We have two databases in 10g Release 2. These databases are on two different servers and we use
Materialized views to replicate data between these servers. We are currently using 64 bit version of
oracle 10g release 2 for LINUX.
Oracle Database 10g Release 10.2.0.1.0 - 64 bit Production
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
We use CENTOS 5 - 64 bit edition
We upgraded one of the databases to 11g (We exported the data from old database and
imported it in new database) . Then we tried to create a Materialized view with incremental refresh
on it where the base table is in the second Oracle 10g database.
The problem is that it is not letting us create the view with FAST Refresh. It kept on giving ORA-12028
error. We tried different remedies suggested on forums like creating a view with ROWID, but still it
continued giving us the same error. We also synchronized the characterset of Oracle 10g and Oracle 11g
installations but still it did not work.
Our base table size is pretty large (over 10 Million records) and if we do a full refresh, it takes hours to
refresh it.
Without incremental refresh, we will not be able to fucntion, and to upgrade both database simultaneously
we will need a large down-time which also we can not afford.
Please advise what should we do.
Best Regards
Madhup
Edited by: Madhup on Mar 2, 2009 10:45 AMHello,
Yesterday I met the same problem and very sad about this, however, my story is much more complicated (I think so).
I have 6 databases:
2 - 11g
2 - 10g
2 - 9i
Every database of each release has different characterset(UTF8 and AL16UTF16).
I am trying to create Materialized view with FAST REFRESH on Oracle 11g, when master tables are located on 10g database and 9i database.
Materialized view, which points to 9i database, was successfully created.
Materialized view, which points to 10g database, gets ORA-12028
Like you, I tried many notes from METALINK and thought at the begining that the problem is my characterset. But, when the materialized views were successfully built on Oracle 9i database, I understood that the problem is something else.
Did you find the actual reason why this issue does not work??
Thanks,
Alex -
Create Materialized View with GROUP BY
I have a table
treecluster NUMBER(3)
treenumber NUMBER(3)
treedate DATE
nestnumber NUMBER(3)
eggs NUMBER(3)
nestlings NUMBER(3)
fledglings NUMBER(3)
nestfate VARCHAR2(10)
nestfailurecode NUMBER(2)
I want to group the data by treecluster, treenumber, year, and nest number and get a max eggs, nestlings, fledglings. I am doing this with the following:
SELECT treecluster, treenumber, to_char(nestchecksdate, 'YYYY'), nestnumber,
max(eggs), max(nestlings), max(fledglings)
FROM nestchecks
GROUP BY treecluster, treenumber, to_char(nestchecksdate, 'YYYY'), nestnumber;
This works fine.
The last record for a year has a nestfate and nestfailurecode value.
I need to group all information and then also get the nestfate and nestfailurecode for the year. How do I go about getting this information?
I am really trying to create a summary materialized view based on a data table so the select I am trying to craft would be a part of a create materialized view as SELECT...
so I want to be able to group the info and add in the nestfate and failurecode in one step.
Thanks!try this:
SQL> select * from table_tree;
TREECLUSTER TREENUMBER NESTCHECK NESTNUMBER EGGS NESTLINGS FLEDGLINGS NESTFATE NESTFAILURECODE
4 167 17-MAY-00 2 0 0
4 167 24-MAY-00 2 3 0
4 167 30-MAY-00 2 3 0
4 167 12-JUN-00 2 0 1 FAILURE 2
select a.treecluster, a.treenumber, to_char(a.nestyear,'YYYY') nestyear,
a.nestnumber, a.eggs, a.nestlings, a.fledglings, a.nestfate, a.nestfailurecode
from (select max(treecluster) treecluster, max(treenumber) treenumber,
max(nestchecksdate) nestyear,
max(nestnumber) nestnumber, max(eggs) eggs, max(nestlings) nestlings,
nvl(max(FLEDGLINGS),0) FLEDGLINGS, max(NESTFATE) NESTFATE,
max(nestfailurecode) nestfailurecode
from table_tree) a
TREECLUSTER TREENUMBER NEST NESTNUMBER EGGS NESTLINGS FLEDGLINGS NESTFATE NESTFAILURECODE
4 167 2000 2 3 1 0 FAILURE 2hope this helps
Maybe you are looking for
-
"System cannot find the path specified" error message !HELP !
Hi In doing a program to read a string from the buffer, I am getting an error message that says "cannot find the file specified" The file was created in a previous program and I verified it does exist at the specified location on my hard disk. Below
-
Field optional in Content Conversion
Hi, This is my data structure Field1 Field2 Field3. I have two source systems which is sending the data. One of the source system sends only Field1 and Field 3, while another source system sends Field1,Field2 and Field3. Should i make the field2 as o
-
Fetch client IP addresses from the Netlogon.log file of all domain controllers in the domain
Hi, The event ID 5807 is logged in the system logs of domain controllers as a result of which the IP addresses for the missing subnets are logged in Netlogon.log under %systemroot%/debug. The end goal is to fetch the IP addresses along with rest of t
-
Require coding for purchase requisation outstanding aging report
Hi Gurus, I got a requirment to develop purchase requisation outstanding aging report.Please provide me the coding for purchase requisation outstanding aging report. Points will be rewarded for every reply. Regards , Sonali.
-
I have a scenario File -> XI -> RFC (Async), XI call a FM to create a Material in R/3, the FM has one table for languages, after mapping the structure goes as follow: <?xml version="1.0" encoding="UTF-8" ?> <ns0:Z_MM_EXTRACT_DATA_TO_MDM_2 xmlns:ns0="