Create materialized view is failing when refresh fast is used
version 10.2.0.4 on solaris
This statement is working fine
CREATE MATERIALIZED VIEW MVIEW1
TABLESPACE MIS_CURD01
BUILD IMMEDIATE
as
SELECT ACTIVITY_ID "ACTIVITY_ID",
ASSOC_ID "ASSOC_ID",
PIT_ROLE_CODE "PIT_ROLE_CODE",
PIT_BANK_CODE "PIT_BANK_CODE",
PIT_COST_CENTER "PIT_COST_CENTER",
RESP_ASSOC_IND "RESP_ASSOC_IND"
FROM TABLE1@DBLINK;
The statement with fast refresh is failing with this error message
ERROR at line 18:
ORA-12018: following error encountered during code generation for
"TABLE1"
ORA-00942: table or view does not exist
Here is the statement
CREATE MATERIALIZED VIEW MVIEW1
TABLESPACE MIS_CURD01
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
USING INDEX TABLESPACE MIS_CURI01
REFRESH FAST ON DEMAND
WITH PRIMARY KEY
AS
SELECT ACTIVITY_ID "ACTIVITY_ID",
ASSOC_ID "ASSOC_ID",
PIT_ROLE_CODE "PIT_ROLE_CODE",
PIT_BANK_CODE "PIT_BANK_CODE",
PIT_COST_CENTER "PIT_COST_CENTER",
RESP_ASSOC_IND "RESP_ASSOC_IND"
FROM TABLE1@DBLINK;
Any idea what's going wrong here. Thanks for your help in advance.
Edited by: user11319873 on Jun 30, 2010 4:17 PM
Refresh FAST requires that
a. An MV Log (Snapshot Log) be created on the source table
b. The user doing the refresh (i.e. the account that the DBLink uses) has SELECT privilege on the MV Log.
Hemant K Chitale
Similar Messages
-
Create materialized view as part of refresh group
Hello,
When I create a materialized view in 11g it automatically creates its own refresh group. How can I create the materialized group as part of an existing refresh group? (I know I can drop the individual refresh group and add the mview to the main refresh group but that is a pain).
Thank you,>
How can I create the materialized group as part of an existing refresh group?
>
You can't - you need to add the MV to the existing refresh group.
See the Add Procedure of the DBMS_REFRESH package
http://docs.oracle.com/cd/B28359_01/server.111/b28327/rarrefreshpac.htm -
ORA-12052 when create materialized view
I following the sample in Oracle document to create materialized viewCREATE MATERIALIZED VIEW LOG ON sales
WITH ROWID, SEQUENCE(amount_sold, time_id, prod_id) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON times
WITH ROWID, SEQUENCE (time_id, calendar_year) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW LOG ON products
WITH ROWID, SEQUENCE (prod_id,prod_name) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW sales_mv
BUILD IMMEDIATE REFRESH FAST ON COMMIT
AS SELECT t.calendar_year, p.prod_id, p.prod_name,
SUM(s.amount_sold) AS sum_sales
FROM times t, products p, sales s
WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id
GROUP BY t.calendar_year, p.prod_id, p.prod_name; This works. BUt I actually does not want do aggregation. Thus I changed the MV creation statement toCREATE MATERIALIZED VIEW sales_mv
BUILD IMMEDIATE REFRESH FAST ON COMMIT
AS SELECT t.calendar_year, p.prod_id, p.prod_name,s.amount_sold
FROM times t, products p, sales s
WHERE t.time_id = s.time_id AND p.prod_id = s.prod_id;I got errorSQL Error: ORA-12052: cannot fast refresh materialized view GLU.SALES_MV
*Cause: Either ROWIDs of certain tables were missing in the definition or
the inner table of an outer join did not have UNIQUE constraints on
join columns.
*Action: Specify the FORCE or COMPLETE option. If this error is got
during creation, the materialized view definition may have be
changed. Refer to the documentation on materialized views.Please help or point me to the relevant document.
Thanksdamorgan, Thank you for you reply.
the inner table of an outer join did not have UNIQUE constraints on join columns.
I am not sure how much clearer and explanation can be written.If you look at the query, you will find that there is no outer join in the query.
sales table does not have unique constraints on prod_id and time_id. If this is the cause of the problem, I cannot change the data but is there a work around. That is way I ask for specific doc. In 11g documents, I only find some info on CREATE MV. That is mainly on syntax but not on requirement. -
Error creating materialized view log using DBlink
Hi guys,
I have 2 databases in diferent machines . (machine A and B)
Machine A is my production database and I have a database link in machine B accessing Machine A
CREATE MATERIALIZED VIEW vm_test
BUILD IMMEDIATE
REFRESH FAST ON commit as
select * from test@A
-- no problem in this first operation the materialized view was created sucessfully
Now I need to create the LOG
SQL> CREATE MATERIALIZED VIEW LOG ON test
2 PCTFREE 5
3 TABLESPACE prodemge_2006
4 STORAGE (INITIAL 10K NEXT 10K);
CREATE MATERIALIZED VIEW LOG ON test
ERROR at line 1:
ORA-02050: transaction 5.21.8771 rolled back, some remote DBs may be in-doubt
ORA-02068: following severe error from A
ORA-03113: end-of-file on communication channel
What could be causing this error ?
Thank you,
FelipeORA-02050 transaction string rolled back, some remote DBs may be in-doubt
Cause: Network or remote failure during a two-phase commit.
Action: Notify operations; remote databases will automatically re-sync when the failure is repaired.
ORA-02068 following severe error from stringstring
Cause: A severe error (disconnect, fatal Oracle error) was received from the indicated database link. See following error text.
Action: Contact the remote system administrator.
M.S.Taj -
Problem creating materialized view
OK, I'm totally new in using materialized views.
I'm trying to create one and to make it refreshed on commit
CREATE MATERIALIZED VIEW VK_CLIENT build immediate refresh fast on commit AS
select c1.code,
c1.fiche fiche_1,
decode( c1.sfam, '04',
decode( c7.sfam, '04', 'M. et Mme', c1.lnte ), c1.lnte ) lnte_1,
decode( c1.sfam, '04',
decode( c7.sfam, '04',
decode( c1.lnte, 'M.', c1.libe, c7.libe ), c1.libe ), c1.libe ) libe_1,
decode( c1.sfam, '04',
decode( c7.sfam, '04',
decode( c1.lnte, 'M.', substr( c1.libe, 1, c1.lgnom ), substr( c7.libe, 1, c7.lgnom ) ), substr( c1.libe, 1, c1.lgnom ) ), substr( c1.libe, 1, c1.lgnom ) ) nom_1,
decode( c1.sfam, '04',
decode( c7.sfam, '04',
decode( c1.lnte, 'M.', initcap( substr( c1.libe, c1.lgnom + 2 ) ), initcap( substr( c7.libe, c7.lgnom + 2 ) ) ), initcap( substr( c1.libe, c1.lgnom + 2 ) ) ), initcap( substr( c1.libe, c1.lgnom + 2 ) ) ) prenom_1,
decode( c1.sfam, '04', decode( c7.sfam, '04', decode( c1.lnte, 'Mlle', 'Mme', c1.lnte ), c1.lnte ), c1.lnte ) lnte_1_bis,
c1.libe libe_1_bis,
substr( c1.libe, 1, c1.lgnom ) nom_1_bis,
initcap( substr( c1.libe, c1.lgnom + 2 ) ) prenom_1_bis,
c1.sfam sfam_1,
c1.dnai dnai_1,
decode( to_char( c1.dnai, 'dd' ), '01', '1er',
decode( substr( to_char( c1.dnai, 'dd' ), 1, 1 ), 0, substr( to_char( c1.dnai, 'dd' ), 2 ), to_char( c1.dnai, 'dd' ) ) ) || ' ' ||
rtrim( to_char( c1.dnai, 'month', 'nls_date_language = french' ) ) || to_char( c1.dnai, ' yyyy' ) dnai_fr_1,
c1.horsfoyer horsfoyer_1,
decode( c1.lnte, 'Mlle', 'f', 'Mme', 'f', 'M.', 'm' ) accord_1,
c7.fiche fiche_7,
decode( c1.sfam, '04',
decode( c7.sfam, '04', null, c7.lnte ), c7.lnte ) lnte_7,
decode( c1.sfam, '04',
decode( c7.sfam, '04', null, c7.libe ), c7.libe ) libe_7,
decode( c1.sfam, '04',
decode( c7.sfam, '04', null, substr( c7.libe, 1, c7.lgnom ) ), substr( c7.libe, 1, c7.lgnom ) ) nom_7,
decode( c1.sfam, '04',
decode( c7.sfam, '04', null, initcap( substr( c7.libe, c7.lgnom + 2 ) ) ), initcap( substr( c7.libe, c7.lgnom + 2 ) ) ) prenom_7,
decode( c7.sfam, '04', decode( c1.sfam, '04', decode( c7.lnte, 'Mlle', 'Mme', c7.lnte ), c7.lnte ), c7.lnte ) lnte_7_bis,
c7.libe libe_7_bis,
substr( c7.libe, 1, c7.lgnom ) nom_7_bis,
initcap( substr( c7.libe, c7.lgnom + 2 ) ) prenom_7_bis,
c7.sfam sfam_7,
c7.dnai dnai_7,
decode( to_char( c7.dnai, 'dd' ), '01', '1er',
decode( substr( to_char( c7.dnai, 'dd' ), 1, 1 ), 0, substr( to_char( c7.dnai, 'dd' ), 2 ), to_char( c7.dnai, 'dd' ) ) ) || ' ' ||
rtrim( to_char( c7.dnai, 'month', 'nls_date_language = french' ) ) || to_char( c7.dnai, ' yyyy' ) dnai_fr_7,
decode( c7.lnte, 'Mlle', 'f', 'Mme', 'f', 'M.', 'm' ) accord_7,
initcap( decode( instr( lower( c1.adr1 ), 'log' ), '1', c1.adr2, decode( instr( lower( c1.adr1 ), 'bât' ), '1', c1.adr2, c1.adr1 ) ) ) adr1,
initcap( decode( decode( instr( lower( c1.adr1 ), 'log' ), '1', c1.adr2, decode( instr( lower( c1.adr1 ), 'bât' ), '1', c1.adr2, c1.adr1 ) ), c1.adr2, null,
decode( instr( lower( c1.adr2 ), 'log' ), '1', c1.adr3, decode( instr( lower( c1.adr2 ), 'bât' ), '1', c1.adr3, c1.adr2 ) ) ) ) adr2,
initcap( decode( instr( lower( c1.adr3 ), 'log' ), '1', null, decode( instr( lower( c1.adr3 ), 'bât' ), '1', null, c1.adr3 ) ) ) adr3,
c1.ptt,
c1.lcom,
decode( c7.fiche, null, decode( c1.lnte, 'Mme', 'Madame', 'Mlle', 'Mademoiselle', 'M.', 'Monsieur', 'Monsieur' ),
decode( nvl( c1.sfam, '07' ), '04',
decode( nvl( c7.sfam, '07' ), '04', 'Madame, Monsieur',
decode( c1.lnte,
'Mme', decode( c7.lnte, 'Mme', 'Mesdames', 'Mlle', 'Madame, Mademoiselle', 'M.', 'Madame, Monsieur', 'Madame, Monsieur' ),
'Mlle', decode( c7.lnte, 'Mme', 'Madame, Mademoiselle', 'Mlle', 'Mesdemoiselles', 'M.', 'Mademoiselle, Monsieur', 'Mademoiselle, Monsieur' ),
'M.', decode( c7.lnte, 'Mme', 'Madame, Monsieur', 'Mlle', 'Mademoiselle, Monsieur', 'M.', 'Mesieurs', 'Mesieurs' ),
'. ', decode( c7.lnte, 'Mme', 'Madame, Monsieur', 'Mlle', 'Mademoiselle, Monsieur', 'M.', 'Mesieurs', 'Mesieurs' ),
decode( c1.lnte,
'Mme', decode( c7.lnte, 'Mme', 'Mesdames', 'Mlle', 'Madame, Mademoiselle', 'M.', 'Madame, Monsieur', 'Madame, Monsieur' ),
'Mlle', decode( c7.lnte, 'Mme', 'Madame, Mademoiselle', 'Mlle', 'Mesdemoiselles', 'M.', 'Mademoiselle, Monsieur', 'Mademoiselle, Monsieur' ),
'M.', decode( c7.lnte, 'Mme', 'Madame, Monsieur', 'Mlle', 'Mademoiselle, Monsieur', 'M.', 'Mesieurs', 'Mesieurs' ),
'. ', decode( c7.lnte, 'Mme', 'Madame, Monsieur', 'Mlle', 'Mademoiselle, Monsieur', 'M.', 'Mesieurs', 'Mesieurs' ),
'-' ) ) ) lnte_long,
decode( c1.cfam, null, c7.cfam, c1.cfam ) cfam,
decode( c1.cfam, null, c7.allo, c1.allo ) allo,
decode( c1.sexe, 'm', decode( c7.sexe, null, 'ms', 'm', 'mp', 'f', 'mp' ), 'f', decode( c7.sexe, null, 'fs', 'm', 'mp', 'f', 'fp' ), '-' ) accord,
c9.fiche fiche_9,
c9.lnte lnte_9,
c9.libe libe_9,
substr( c9.libe, 1, c9.lgnom ) nom_9,
initcap( substr( c9.libe, c9.lgnom + 2 ) ) prenom_9,
initcap( decode( instr( lower( c9.adr1 ), 'log' ), '1', c9.adr2, decode( instr( lower( c9.adr1 ), 'bât' ), '1', c9.adr2, c9.adr1 ) ) ) adr1_9,
initcap( decode( decode( instr( lower( c9.adr1 ), 'log' ), '1', c9.adr2, decode( instr( lower( c9.adr1 ), 'bât' ), '1', c9.adr2, c9.adr1 ) ), c9.adr2, null,
decode( instr( lower( c9.adr2 ), 'log' ), '1', c9.adr3, decode( instr( lower( c9.adr2 ), 'bât' ), '1', c9.adr3, c9.adr2 ) ) ) ) adr2_9,
initcap( decode( instr( lower( c9.adr3 ), 'log' ), '1', null, decode( instr( lower( c9.adr3 ), 'bât' ), '1', null, c9.adr3 ) ) ) adr3_9,
c9.ptt ptt_9,
c9.lcom lcom_9,
decode( c9.lnte, 'Mlle' , 'Mademoiselle', 'Mme', 'Madame', 'M.', 'Monsieur', 'M. et Mme', 'Madame, Monsieur', null ) lnte_long_9,
decode( c9.sexe, 'm', 'ms', 'f', 'fs', null, null, '-' ) accord_9,
no.nbocc
from client c1,
client c7,
client c9,
select z.code code,
count(*) nbocc
from client z
where to_char( sysdate, 'yyyymmdd' ) between to_char( z.cdeb, 'yyyymmdd' ) and to_char( nvl( z.cfin, sysdate ), 'yyyymmdd' )
group by z.code
) no
where c1.code = c7.code (+)
and c1.role = '1'
and c7.role (+) ='7'
and nvl( c7.horsfoyer (+), 0 ) = '0'
and to_char( nvl( c7.cfin (+), sysdate ), 'yyyymmdd' ) >= to_char( sysdate, 'yyyymmdd' )
and c1.code = c9.code (+)
and c9.role (+) = '9'
and to_char( nvl( c9.cfin (+), sysdate ), 'yyyymmdd' ) >= to_char( sysdate, 'yyyymmdd' )
and c9.lnte (+) not in ( '. ', 'Assoc.', 'Ste' )
and c9.lcom (+) is not null
and c1.code = no.code (+);when doing so, I'm getting a ORA-12054:
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.
When I create the materialized view with just CREATE MATERIALIZED VIEW "H6801_GL_00"."VK_CLIENT" AS
it works but the refresh is only "ON DEMAND"...
Can't find how and why it won't work...
Edited by: MacFizz on Dec 17, 2009 3:22 PMYou could try the DBMS_MVIEW.TUNE_MVIEW and check if you can modify you materialized view or "refactor" it in a smaller, fast refreshable part that you could combine later to the sysdate/rownum part of it.
http://download.oracle.com/docs/cd/E11882_01/server.112/e10821/advisor.htm
Explanation on restrictions of fast refresh:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm
Below there's an example of a fast refreshable mview, on creating the materialized view log and so on:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/statements_6002.htm#i2080820 -
Create materialized view in SE referring table in EE
Hi DBAs,
I am trying to create a Materialized view on Oracle 10g Standard Edition which is installed on Linux Debian Lenny.
The master table is on Oracle 10g Enterprise Edition installed on Red Hat Linux 4.1.2.
When I run,
create materialized view t1 build immediate refresh fast as (select * from aksharaemsmigrated.t1@db102)
i get,
ORA-12028: materialized view type is not supported by master site
When I run,
create materialized view t1 build immediate refresh fast on commit as (select * from aksharaemsmigrated.t1@db102);
I get,
ORA-01031: insufficient privileges
When I run,
select * from aksharaemsmigrated.t1@db102
I get,
the rows from aksharaemsmigrated.t1@db102
NOTE: 'db102' is remote DB on 10g EE for which I created db link.
I am able to create Mview for local table.
Is this not supported? I mean creating Mview on Oracle SE referring base table from Oracle EE.
I have to give solution soon. Can you please throw some light.
Regards,
VijayDon't put select statement inside parantheses.
Test these
create table x1 as select * from aksharaemsmigrated.t1@db102;
create materialized view t1 build immediate refresh fast as select * from aksharaemsmigrated.t1@db102 ;Note that you cannot create an MV that is REFRESH ON COMMIT when across Databases.
See my explanation at http://hemantoracledba.blogspot.com/2008/06/mvs-with-refresh-on-commit-cannot-be.html
Hemant K Chitale -
Error on "CREATE MATERIALIZED VIEW"
I tried to create this materialized view:
CREATE MATERIALIZED VIEW mv_cost_est
BUILD IMMEDIATE
REFRESH complete
START WITH to_date(sysdate,'dd/mm/yyyy hh24:mi:ss')
NEXT sysdate + 60/86400
disable QUERY REWRITE
AS
SELECT
efm_contratti.contratto_id,
efm_commesse.dp_id,
x.wr_id,
(select max(cost_class_attiva) from efm_cost_cat_passivo_attivo
where x.cost_class_id = efm_cost_cat_passivo_attivo.cost_class_passiva
and x.cost_cat_id = efm_cost_cat_passivo_attivo.cost_cat_passiva
) AS classe_costo,
(select max(cost_cat_attiva) from efm_cost_cat_passivo_attivo
where x.cost_cat_id = efm_cost_cat_passivo_attivo.cost_cat_passiva
and x.cost_class_id = efm_cost_cat_passivo_attivo.cost_class_passiva) as cat_costo,
x.cost_est_total,
(SELECT CASE
WHEN status IN ('I','SA') and ( (TO_DATE(LAST_DAY(SYSDATE)) > wr.date_est_start) or wr.pct_complete > 0 ) THEN
(case
when wr.pct_complete > 0 then
(wr.cost_est_total * wr.pct_complete /100 * (1 + pct_ricarico/100))
when (wr.pct_complete = 0 and wr.date_est_end = wr.date_est_start and wr.date_est_end < TO_DATE(LAST_DAY(SYSDATE))) then
(wr.cost_est_total * (1 + pct_ricarico/100))
when (wr.pct_complete = 0 and wr.date_est_end > TO_DATE(LAST_DAY(SYSDATE)) ) then
(wr.cost_est_total * ((TO_DATE(LAST_DAY(SYSDATE)) - wr.date_est_start) / (wr.date_est_end - wr.date_est_start) ) * (1 + pct_ricarico/100))
when (wr.pct_complete = 0 and wr.date_est_end < TO_DATE(LAST_DAY(SYSDATE)) ) then
(wr.cost_est_total * (1 + pct_ricarico/100))
when (wr.pct_complete = 0 and wr.date_est_end = TO_DATE(LAST_DAY(SYSDATE))) then
(wr.cost_est_total * (1 + pct_ricarico/100))
END)
WHEN status = 'Com' THEN cost_est_total * (1 + pct_ricarico/100)
WHEN status = 'CON' THEN cost_total * (1 + pct_ricarico/100)
WHEN status = 'BEN' THEN cost_total * (1 + pct_ricarico/100)
else
0
end
from wr where wr.wr_id=x.wr_id) as IMPORTO1,
'EUR',
efm_commesse.ac_id,
project.project_id,
project.project_type,
x.status,
x.cost_est_total,
x.cost_total,
x.pct_complete,
(SELECT CASE
WHEN status IN ('I','SA') THEN
(case
when wr.pct_complete = 0 and wr.date_est_start = wr.date_est_end and wr.date_est_end < TO_DATE(LAST_DAY(SYSDATE)) then
100
when wr.pct_complete = 0 and wr.date_est_end > TO_DATE(LAST_DAY(SYSDATE)) then
round (((TO_DATE(LAST_DAY(SYSDATE)) - wr.date_est_start) / (wr.date_est_end - wr.date_est_start)*100), 2)
when wr.pct_complete = 0 and wr.date_est_end < TO_DATE(LAST_DAY(SYSDATE)) then
100
when wr.pct_complete = 0 and wr.date_est_end = TO_DATE(LAST_DAY(SYSDATE)) then
100
when wr.pct_complete > 0 then
wr.pct_complete
END)
WHEN status = 'Com' THEN 100
WHEN status = 'CON' THEN 100
WHEN status = 'BEN' THEN 100
else
0
end
from wr where wr.wr_id=x.wr_id) as SAL_CALCOLATO,
x.pct_ricarico,
x.commessa_id,
x.cost_class_id,
x.cost_cat_id
FROM
wr x, cf, efm_contratti, efm_commesse, project,wrbennonfattura
WHERE x.cf_id=cf.cf_id
AND x.commessa_id=efm_commesse.commessa_id
AND x.contratto_id=efm_contratti.contratto_id
AND x.project_id=project.project_id
AND efm_commesse.status not in ('Closed')
and x.wr_id=wrbennonfattura.wr_id
and project.project_type in ('03','10')
AND x.cost_class_id is not null
but I get this error:
ORA-22818: subquery expressions not allowed here
How can I rewrite my query to avoid this error?
Thanks in advance!I'm sorry, the solution I gave above may not be correct. Try http://download.oracle.com/docs/cd/B19306_01/server.102/b14200.pdf - section 15-6. And the solution may be:
ORA-22818: subquery expressions not allowed here
Cause: An attempt was made to use a subquery expression where these are not supported.
Action: Rewrite the statement without the subquery expression. -
Create Materialized View based on another database table using db link?
SQL> SELECT sysdate
2 FROM dual@CBRLINK ;
SYSDATE
21-NOV-12
SQL> CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
2 REFRESH COMPLETE
3 START WITH SYSDATE NEXT SYSDATE + (5/24)
4 AS
5 SELECT sysdate
6 FROM dual@CBRLINK ;
CREATE MATERIALIZED VIEW USERCBR.V_T24_COUNTRY1
ERROR at line 1:
ORA-04052: error occurred when looking up remote object SYS.DUAL@CBRLINK
ORA-00600: internal error code, arguments: [ORA-00600: internal error code,
arguments: [qksfroFXTStatsLoc() - unknown KQFOPT type!], [0], [], [], [], [],
ORA-02063: preceding line from CBRLINKIt works for me:orcl>
orcl> CREATE MATERIALIZED VIEW scott.V_T24_COUNTRY1
2 REFRESH COMPLETE
3 START WITH SYSDATE NEXT SYSDATE + (5/24)
4 AS
5 SELECT sysdate
6 FROM dual@l1 ;
Materialized view created.
orcl> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 32-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
orcl>so there is no problem with the code. HTH. -
Create materialized view get ora-00998 error cause by subquery
hi all,
my create statement as follow,
create materialized view MV_DM_DIM_DEALER01
Build deferred
Refresh complete
ON DEMAND
Enable query rewrite
as
select a.dealer_no,a.sk_period from DM_DIM_DEALER a
where A.SK_PERIOD=201210 and a.dealer_no in (select dealer_No from dm00_fav_dealer)
ORA-00998: must name this expression with a column alias
so what's the problem?
thx all>
my create statement as follow,
create materialized view MV_DM_DIM_DEALER01
Build deferred
Refresh complete
ON DEMAND
Enable query rewrite
as
select a.dealer_no,a.sk_period from DM_DIM_DEALER a
where A.SK_PERIOD=201210 and a.dealer_no in (select dealer_No from dm00_fav_dealer)
ORA-00998: must name this expression with a column alias
so what's the problem?
>
Well since the error is 'ORA-00998: must name this expression with a column alias' you might try naming your expressions with aliases
select a.dealer_no dealer_no,a.sk_period sk_period from DM_DIM_DEALER a -
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 -
MATERIALIZED view on two tables with Fast Refresh
i Wanted to create MV on two tables with Fast refresh on commit.
I followed below steps
create materialized view log on t1 WITH PRIMARY KEY, rowid;
create materialized view log on t2 WITH PRIMARY KEY, rowid;
CREATE MATERIALIZED VIEW ETL_ENTITY_DIVISION_ASSO_MV
REFRESH fast ON commit
ENABLE QUERY REWRITE
AS
select A.ROWID B.ROWID,a.c1, DECODE(a.c1,'aaa','xxx','aaa') c2
from t1 A
join t2 b
on AB.c1= CD.c2;
i am getting below error.
Error report:
SQL 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.
Basically i want to take record in MV by joinig two tables and if both of the base tables will updated then record should reflect in materialised view.
Please do the needfull.does the table support PCT? the other restrictions on joins look to be ok in your statement.
maybe try creating first with on demand instead of commit to see does it create.
http://docs.oracle.com/cd/B19306_01/server.102/b14223/basicmv.htm
>
Materialized Views Containing Only Joins
Some materialized views contain only joins and no aggregates, such as in Example 8-4, where a materialized view is created that joins the sales table to the times and customers tables. The advantage of creating this type of materialized view is that expensive joins will be precalculated.
Fast refresh for a materialized view containing only joins is possible after any type of DML to the base tables (direct-path or conventional INSERT, UPDATE, or DELETE).
A materialized view containing only joins can be defined to be refreshed ON COMMIT or ON DEMAND. If it is ON COMMIT, the refresh is performed at commit time of the transaction that does DML on the materialized view's detail table.
If you specify REFRESH FAST, Oracle performs further verification of the query definition to ensure that fast refresh can be performed if any of the detail tables change. These additional checks are:
A materialized view log must be present for each detail table unless the table supports PCT. Also, when a materialized view log is required, the ROWID column must be present in each materialized view log.
The rowids of all the detail tables must appear in the SELECT list of the materialized view query definition.
If some of these restrictions are not met, you can create the materialized view as REFRESH FORCE to take advantage of fast refresh when it is possible. If one of the tables did not meet all of the criteria, but the other tables did, the materialized view would still be fast refreshable with respect to the other tables for which all the criteria are met. -
Create materialized view failed!
I want to create a mv from a table which does not contain primary key constraint,but failed. why?
SQL> Create Table tb_test01
2 (
3 Id Number,
4 Name Varchar2(1024)
5 );
Table created.
SQL>
SQL> Create Materialized View Log On tb_test01
2 With Sequence,Rowid(Id,Name)
3 Including New Values;
Materialized view log created.
SQL> Create Materialized View mv_tb_test01
2 Refresh Fast On Commit
3 As
4 Select * From tb_test01;
Select * From tb_test01
ERROR at line 4:
ORA-00604: error occurred at recursive SQL level 1
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 7
ORA-12014: table 'TB_TEST01' does not contain a primary key constraint12014, 00000, "table '%s' does not contain a primary key constraint"
// *Cause: The CREATE MATERIALIZED VIEW LOG command was issued with the
// WITH PRIMARY KEY option and the master table did not contain
// a primary key constraint or the constraint was disabled.
// *Action: Reissue the command using only the WITH ROWID option, create a
// primary key constraint on the master table, or enable an existing
// primary key constraint. -
Create materialized View fails with "table or view does not exist"
DB: 10.2.0.4
OS: Win 2003
Hi,
Here in my tests, i have 2 databases (A(source) and B(backup)), and i am trying to create an mview in database B to replicate data from one test table from database A, only for test purpose. I'm getting the error "table or view does not exist" when i try to create a mview with REFRESH FAST. Here is my code:
CREATE MATERIALIZED VIEW TESTES.TAB_TESTES_REPLIC_MVIEW_02
REFRESH FAST
START WITH TO_DATE('21/02/2012 18:50:00', 'DD/MM/YYYY HH24:MI:SS')
NEXT SYSDATE + 1/24/60
WITH PRIMARY KEY
AS SELECT REGISTRO1,
REGISTRO2
FROM TESTES.TAB_TESTES_REPLIC_MVIEW_02@DB_LINK_ORA10;
The dblink is workig fine(dblink user has select privilege on TESTES.TAB_TESTES_REPLIC_MVIEW_02), and i have created the mview log on database A.
Where is my mistake.
Thanks a lot.
Edited by: Fabricio_Jorge on 21/02/2012 19:06I found the solution.
I had to grant SELECT on the mview log. The name is avaiable in DBA_MVIEW_LOGS -
"Invalid Metadata Objects" when creating materialized views
Hi experts,
I have run into some trouble. I had an analytic workspace that grew too fast (see 11.2.0.2 AW size grows steadily with every cube build so I deleted it and created a new one.
It seemed to build fine using the tip that David Greenfield gave us in the mentioned forum post, but when I try to enable materialized views (which I had enabled in the previous workspace) I'm gettig the following error:
Your metadata changes have been saved, with the following errors
Invalid Metadata Objects:
Invalid Object "TABLESPACE.LECTURAS": "CREATE MATERIALIZED VIEW "TABLESPACE"."CB$LECTURAS"
ORGANIZATION CUBE ON TABLESPACE.TABLESPACE_AW(
FACT "LECTURAS_STORED"("LECTURAS_MEASURE_DIM" 'LECTURA') IS "LECTURA",
DIMENSION "TIEMPO" IS "TIEMPO" USING "TIEMPO_TIEMPO_HOUR_ID_UNIQUE_KEY" ,
DIMENSION "GEOGRAFIA" IS "GEOGRAFIA" USING "GEOGRAFIA_GEOGRAFIA_CONTADOR_ID_UNIQUE_KEY" )
BUILD DEFERRED
REFRESH ON DEMAND
FORCE
USING TRUSTED CONSTRAINTS
AS
SELECT
TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') "TIEMPO",
T1."COD_METERID" "GEOGRAFIA",
SUM(T1."VAL_AI_HOR") "LECTURA"
FROM
TABLESPACE."LECTURA_HORARIA_FINAL" T1
GROUP BY
(TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') , T1."COD_METERID")
ORA-00942: table or view does not exist
Running this same script in SQLDeveloper yields the same error at line 17, which is the FROM clause. BUT I can run the SELECT statement by itself and returns the expected result. So the table exists in the correct tablespace.
I must be missing something big...
Thanks in advance.
Joan
P.S.: In the code above I'm using "TABLESPACE" in substitution for the real username and tablespace name (which is the same) for privacy reasons.When you ran the select statement, were you connected as the same user that you used to try to enable the MVs?
Can you create a standard (non cube) MV with the same select statement? (Connected as the same user you used in AWM.)
"CREATE MATERIALIZED VIEW "TABLESPACE"."MV_TEST"
BUILD DEFERRED
REFRESH ON DEMAND
FORCE
USING TRUSTED CONSTRAINTS
AS
SELECT
TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') "TIEMPO",
T1."COD_METERID" "GEOGRAFIA",
SUM(T1."VAL_AI_HOR") "LECTURA"
FROM
TABLESPACE."LECTURA_HORARIA_FINAL" T1
GROUP BY
(TO_CHAR(T1."FEC_LECTURA", 'dd/mm/yyyy hh24:mi:ss') , T1."COD_METERID")
{code} -
Error when Create Materialized View
Hi
When I tried to create MV show me error :
SQL> @CRIA_MV_ARC_BW.SQL
AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
ERROR at line 88:
ORA-01031: insufficient privilegesI am using Oracle 9.02 and there are Grant for all Tablles , my query of creation is:
CREATE MATERIALIZED VIEW CLIBGF.MV_ARC_BW
NOCACHE
LOGGING
NOPARALLEL
BUILD IMMEDIATE
REFRESH FORCE
START WITH TO_DATE('26-nov-2009 02:00:00','dd-mon-yyyy hh24:mi:ss')
NEXT trunc(sysdate) + 1/12
ENABLE QUERY REWRITE
AS
SELECT MAX(NVL((SELECT DECODE(A.T$CDNG$O,'F',DECODE(TRIM(B.T$CALC$O),'S','C',A.T$CDNG$O),A.T$CDNG$O)
FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
AND A.T$NDOC$O = NOTAS.CD_NOTA
AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)
AND ROWNUM =1),
0)) NEGOCIO,
ARC.CD_CLIENTE CD_CLIENTE,
CLIENTE.T$NAMA DS_CLIENTE,
ARC.CD_ARC,
ARC.CD_STATUS,
ARC.CD_STATUS || ' - ' || STATUS.DS_STATUS STATUS,
TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY') DT_EMISSAO,
TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY') DT_REALIZADO_INVESTIGACAO,
ARC.CD_MARCA || ' - ' || MARCA.T$DSMA$O MARCA,
ARC.CD_PRODUTO CD_PRODUTO,
EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O DS_EMBALAGEM,
SUBSTR(ARC.DS_ARC, 1, 3) CD_COMPANHIA_PRODUTORA,
ARC.CD_MOTIVO_RECLAMACAO CD_MOTIVO_RECLAMACAO,
MOTIVO.DS_ITEM DS_MOTIVO_RECLAMACAO,
DECODE(ARC.FL_PROCEDENCIA, 0, 'PROCEDENTE', 1, 'IMPROCEDENTE', ' ') PROCEDENCIA,
SUM(NVL((SELECT SUM(NVL(T$IQUA$O, 0))
FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
AND A.T$NDOC$O = NOTAS.CD_NOTA
AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)),
0)) NR_QUANTIDADE_VENDIDA,
ARC.NR_QUANTIDADE_AFETADA NR_QUANTIDADE_AFETADA,
ARC.NR_QUANTIDADE_AFETADA_REAL NR_QUANTIDADE_AFETADA_REAL,
DS_JUSTIFICATIVA DSJUST
FROM ARCTB_ARC ARC,
ARCTB_NOTAS NOTAS,
ARCTB_TABELA_MOTIVO MOTIVO,
ARCTB_ACAO_IMEDIATA ACAO_INV,
ARCTB_ACAO_IMEDIATA ACAO_IME,
ARCTB_STATUS STATUS,
TRITON.TTCCOM010501 CLIENTE,
TRITON.TTCCOM936501 CIDADE,
TRITON.TTIITM001810 D,
TRITON.TTIITM983501 PRODUTO,
TRITON.TTFGLD010806 CC,
TRITON.TTCCOM983501 MARCA,
TRITON.TTCCOM000501 CIA,
TRITON.TTIITM982501 NAT,
SEI.SIBTB_MULTIMARCA MULTIMARCA,
SEI.SIBTB_DIRETORIA_DEPTO DIRETORIA,
TRITON.TTCCOM994501 USUARIO,
ARCTB_GERENCIA_INDUSTRIAL INDUSTRIAL,
TRITON.TTIITM984501 EMBALAGEM
WHERE ARC.CD_ARC = NOTAS.CD_ARC(+)
AND ARC.CD_ARC = ACAO_INV.CD_ARC(+)
AND ACAO_INV.CD_TIPO_ACAO(+) = 0
AND ACAO_INV.CD_ACAO_IMEDIATA(+) = 999
AND ARC.CD_ARC = ACAO_IME.CD_ARC(+)
AND ACAO_IME.CD_TIPO_ACAO(+) = 1
AND ACAO_IME.CD_ACAO_IMEDIATA(+) = 999
AND ARC.CD_CLIENTE = CLIENTE.T$CUNO(+)
AND CLIENTE.T$ESTA$L = CIDADE.T$ESTA$L(+)
AND CLIENTE.T$CDMU$L = CIDADE.T$MUNI$L(+)
AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
TRIM(REPLACE(D.T$ITEM(+), '-', ''))
AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
TRIM(REPLACE(PRODUTO.T$ITEM$O(+), '-', ''))
AND PRODUTO.T$PROC$O = NAT.T$PROC$O(+)
AND EMBALAGEM.T$CDAC$O(+) = PRODUTO.T$CDAC$O
AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
AND ARC.CD_MARCA = MARCA.T$CDMA$O(+)
AND SUBSTR(ARC.DS_ARC, 1, 3) = CIA.T$NCMP(+)
AND ARC.CD_STATUS = STATUS.CD_STATUS(+)
AND TRIM(ARC.CD_CENTRO_CUSTO) = TRIM(CC.T$DIMX(+))
AND CC.T$DTYP(+) = 2
AND CC.T$SUBL(+) = 0
AND ARC.CD_DEPTO_MULTIMARCA = MULTIMARCA.CD_MULTIMARCA(+)
AND ARC.CD_DEPTO = DIRETORIA.CD_DEPTO(+)
AND ARC.CD_USUARIO = TRIM(USUARIO.T$CDUS$O(+))
AND ARC.CD_STATUS IS NOT NULL
AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
GROUP BY TO_CHAR(ARC.DT_EMISSAO, 'YYYY'),
TO_CHAR(ARC.DT_EMISSAO, 'MM'),
ARC.CD_ARC,
ARC.DS_ARC,
ARC.DS_SUPERVISOR,
ARC.CD_STATUS,
STATUS.DS_STATUS,
TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY'),
TO_CHAR(ACAO_INV.DT_ORIGINAL, 'DD/MM/YYYY'),
TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY'),
TO_CHAR(ACAO_IME.DT_ORIGINAL, 'DD/MM/YYYY'),
TO_CHAR(ACAO_IME.DT_REALIZADO, 'DD/MM/YYYY'),
TO_CHAR(ARC.DT_PROCEDENCIA, 'DD/MM/YYYY'),
TO_CHAR(ARC.DT_RECEBIMENTO, 'DD/MM/YYYY'),
TO_CHAR(NVL(ARC.DT_APROVACAO_INDUSTRIAL,
ARC.DT_APROVACAO_COMERCIAL),
'DD/MM/YYYY'),
ARC.CD_CLIENTE,
CLIENTE.T$NAMA,
CIDADE.T$DSCA$L,
ARC.CD_MARCA,
MARCA.T$DSMA$O,
ARC.CD_PRODUTO,
D.T$SEAK,
EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O,
NAT.T$DESC$O,
ARC.NR_LOTE,
ARC.DT_FABRICACAO,
SUBSTR(ARC.DS_ARC, 1, 3),
CIA.T$CITY,
ARC.CD_MOTIVO_RECLAMACAO,
MOTIVO.DS_ITEM,
DECODE(ARC.FL_PROCEDENCIA,
0,
'PROCEDENTE',
1,
'IMPROCEDENTE',
ARC.DS_DISPOSICAO,
ARC.CD_CENTRO_CUSTO,
CC.T$DESC,
ARC.NR_QUANTIDADE_AFETADA,
DS_JUSTIFICATIVA,
DS_DISPOSICAO,
CD_RESPONSAVEL_CAUSA,
ARC.NR_QUANTIDADE_AFETADA_REAL,
ARC.DT_ATENDIMENTO,
MOTIVO.CLASSIFICACAO,
ARC.DS_COORDENADOR,
ARC.FL_ATENDIMENTO,
TO_CHAR(ARC.DT_ATENDIMENTO, 'DD/MM/YYYY'),
ARC.DS_COORDENADOR_INVESTIGACAO,
INDUSTRIAL.REGIAO
ORDER BY ARC.CD_ARC DESC;
Edited by: muttleychess on Nov 25, 2009 10:25 AMPlease see my privilege
GRANTEE PRIVILEGE ADM
CLIBGF CREATE TABLE NO
CLIBGF CREATE ANY VIEW NO
CLIBGF CREATE SNAPSHOT NO
CLIBGF SELECT ANY TABLE NO
CLIBGF CREATE ANY TRIGGER NO
CLIBGF CREATE ANY SNAPSHOT NO
Maybe you are looking for
-
I have the old windows on my computer and would like your expertise:)
-
Can not copy text from a pdf file
https://sites.google.com/site/sharedacrobat/data/cannot_copy_text.pdf?attredirects=0&d=1 I can not copy the table caption in the above pdf. If I do so, I will get some gibberish, such as %"/*&+%",-.%&1",/*%9&,*09%& I'm wondering what happens to the p
-
ORA-29279: SMTP permanent error: 501 5.5.2
im getting the error ORA-29279: SMTP permanent error: 501 5.5.2 Syntax error in parameters scanning "FROM" kindly help . What is the problem exactly?
-
I need some direction with a implementation plan for sharepoint 2013. I want to present a common sharepoint interface to my remote users but they will also need to run applications on my network. will I have to bring up RDS or something similar in
-
Need to know how to find the DML statment in a form session
We are using some user interface forms generated by forms-10g. I would like to know what are the DML commands related to a transaction after we commit a transaction thru the form? Its just displaying transaction completed sucessfully. But how to know