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.
Similar Messages
-
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 -
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 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; -
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 -
Error while creating Materialized Views
I tried creating Materialized views with set operator, and Oracle throws up an error message
ORA-30370: set operators are not supported in this context
The script,
CREATE MATERIALIZED VIEW ORADBA2.MV_GP_AGG_00055_MMR1
PCTFREE 0 TABLESPACE GPMTSPOC
STORAGE (INITIAL 128K NEXT 128K MAXEXTENTS UNLIMITED)
BUILD IMMEDIATE
REFRESH COMPLETE
ENABLE QUERY REWRITE
AS
SELECT * FROM tb_gp_agg_00055r1_01
WHERE srce_sys_cd = 15
UNION ALL
SELECT * FROM tb_gp_agg_00055r1_02
WHERE srce_sys_cd = 15
UNION ALL
SELECT * FROM tb_gp_agg_00055r1_03
WHERE srce_sys_cd = 15;
Will Oracle support UNION clause in Materialized Views?? Any work arounds ?? Thanks.
nullSET operators cannot be used in MATERIALIZED VIEWS.
A workaround is that you create a table AS SELECT using the SET operators and then create the materialized view from that table.
But then you'll not be able to take advantage of QUERY REWRITE AND AUTOMATIC REFRESH.
But if you would still like to have the materialized view then this will work!! -
Illegal use of LONG datatype error message when i create materialized view
Hello to all
I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
I recieve this error message
CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
Error report:
SQL Error: ORA-00997: illegal use of LONG datatype
00997. 00000 - "illegal use of LONG datatype"
Do you know any resort solution for it?
thanksYou can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
example function
-- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
(pass in the primary key columns for the table)
RETURN VARCHAR2
IS
v_long VARCHAR2(32767) ;
BEGIN
BEGIN
-- need to select the long column into the PL/SQL variable
SELECT long_column
INTO v_long
FROM MDB.TOAD_PLAN_TABLE
WHERE key_columns = passed columns ;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = '-01406' THEN
NULL ;
ELSE
RAISE ;
END IF ;
END ;
RETURN SUBSTR(v_long,1,4000) ;
END ;
Then when you create the materialized view utilize that function on the long column.
create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
AS
SELECT column1, .... columnx,
MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
FROM MDB.TOAD_PLAN_TABLE@arahisto ;
See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
Mike -
CREATE MATERIALIZED VIEW ORA-00957
Hi
I have tried using this query to create a MVIEW and I get an ORA-00957 (duplicate column name)
select t.month
,t.year
,t.entity_code
,t.itemref_local
,t.qty
,t.revenue
,t.cogs
,t.ppv
,t.FD
,t.var_labor
,t.var_ovhd
,n.code entity_code
,n.name entity_name
,n.finance_responsible
,c.local_name
,c.emea_name
,c.segment
,c.country
,c.origin_entity
,c.icp_code
,c.type
,c.rmm
,c.sales_rep
,c.sales_leader
,c.emea_director
,c.nat_accounts
,o.code country_code
,o.NAME country_name
,o.REGION country_region
,e.ELIMINATED
,i.PART_NUMBER
,i.DESCRIPTION part_description
,i.PRODUCT_GROUP
,i.LINE
,i.CATEGORY
,i.FAMILY
,i.RANGE
,i.SUPPLIER
,i.PLM
FROM hsce_transactions T
, hsce_entity N
, hsce_customers C
, hsce_country O
, hsce_elim E
, HSCE_ITEMS I
, HSCE_MAPPING M
WHERE T.entity_code = N.code
AND T.customer_code = C.customer_code
AND C.ICP_CODE = E.ICP_CODE
AND C.country = O.code
AND T.ITEMREF_LOCAL = M.ITEM_REF
and M.PART_NUMBER = I.PART_NUMBERCan anyone point me to where I have gone wrong?
Thanks
AdamI'm getting the duplicate column name on my query as well; however the validate feature in Toad, validated the query. I can select and even try to tune the query. therefore, I don't understand the error.
CREATE MATERIALIZED VIEW SYSADM.BAHAR_MV
STORAGE (
BUFFER_POOL DEFAULT
NOCACHE
NOLOGGING
COMPRESS
NOPARALLEL
BUILD IMMEDIATE
USING INDEX
STORAGE (
BUFFER_POOL DEFAULT
REFRESH COMPLETE ON DEMAND
WITH ROWID
USING DEFAULT LOCAL ROLLBACK SEGMENT
AS
/* Formatted on 2009/02/12 13:55 (Formatter Plus v4.8.7) */
SELECT a.business_unit, a.deptid, a.jobcode, a.emplid, f.oth_hrs, f.oth_earns,
h.gl_expense, f.erncd, d.descr, b.descr, c.descr, g.NAME, c.setid,
c.effdt, b.setid, b.deptid, b.effdt, e.check_dt, a.pay_end_dt,
i.ah89_ldr_summary, i.ah89_ldr_summ_grp
FROM ps_pay_earnings_bk a,
ps_bus_unit_tbl_hr d,
ps_pay_calendar e,
ps_pay_oth_earns f,
ps_pay_check g,
ps_earnings_tbl h,
ps_jobcode_tbl c,
ps_job j,
ps_emplmt_srch_qry j1,
ps_dept_tbl b,
ps_ah89_ldr_mappng i
WHERE j.jobcode = a.jobcode
AND j.business_unit = d.business_unit
AND j.setid_dept = d.business_unit
AND j.jobcode = c.jobcode
AND j.emplid = a.emplid
AND j.emplid = j1.emplid
AND j.empl_rcd = j1.empl_rcd
AND j.effdt =
(SELECT MAX (j_ed.effdt)
FROM ps_job j_ed
WHERE j.emplid = j_ed.emplid
AND j.empl_rcd = j_ed.empl_rcd
AND j_ed.effdt <= a.pay_end_dt)
AND j.effseq =
(SELECT MAX (j_es.effseq)
FROM ps_job j_es
WHERE j.emplid = j_es.emplid
AND j.empl_rcd = j_es.empl_rcd
AND j.effdt = j_es.effdt)
AND j.setid_jobcode = c.setid
AND j1.oprid = 'RECPRCSS'
AND a.company = f.company
AND a.paygroup = f.paygroup
AND a.pay_end_dt = f.pay_end_dt
AND a.off_cycle = f.off_cycle
AND a.page_num = f.page_num
AND a.line_num = f.line_num
AND a.addl_nbr = f.addl_nbr
AND a.company = g.company
AND a.paygroup = g.paygroup
AND a.pay_end_dt = g.pay_end_dt
AND a.off_cycle = g.off_cycle
AND a.page_num = g.page_num
AND a.line_num = g.line_num
AND a.sepchk = g.sepchk
AND a.business_unit = b.setid
AND a.company = e.company
AND a.paygroup = e.paygroup
AND a.pay_end_dt = e.pay_end_dt
AND h.erncd = f.erncd
AND h.erncd = i.erncd
AND b.deptid = a.deptid
AND h.effdt = (SELECT MAX (h_ed.effdt)
FROM ps_earnings_tbl h_ed
WHERE h.erncd = h_ed.erncd AND h_ed.effdt <= a.pay_end_dt)
AND c.effdt =
(SELECT MAX (c_ed.effdt)
FROM ps_jobcode_tbl c_ed
WHERE c.setid = c_ed.setid
AND c.jobcode = c_ed.jobcode
AND c_ed.effdt <= SYSDATE)
AND b.effdt =
(SELECT MAX (b_ed.effdt)
FROM ps_dept_tbl b_ed
WHERE b.setid = b_ed.setid
AND b.deptid = b_ed.deptid
AND b_ed.effdt <= SYSDATE)
AND EXISTS (SELECT i.rowsecclass
FROM ps_scrty_tbl_dept i
WHERE i.rowsecclass = 'DPALL' AND i.setid = a.business_unit); -
Problem in creating MATERIALIZED VIEW
Hello All,
I am trying to create the following materialized view and getting this error
SQL> CREATE MATERIALIZED VIEW system_active_loss_mv
2 BUILD IMMEDIATE
3 REFRESH FAST ON COMMIT
4 ENABLE QUERY REWRITE
5 AS
6 SELECT zone_name,
7 EXTRACT(YEAR FROM active_loss_datetime)|| EXTRACT(MONTH FROM active_loss_datetime) as
active_loss_period,
8 count(*) ,
9 count(active_qloss),
10 SUM(active_qloss) as active_qloss,
11 SUM(active_ploss) as active_ploss,
12 SUM(active_gain) as active_gain
13 FROM system_active_loss_day
14 GROUP BY zone_name,
15 EXTRACT(YEAR FROM active_loss_datetime),
16 EXTRACT(MONTH FROM active_loss_datetime);
FROM system_active_loss_day
ERROR at line 13:
ORA-01031: insufficient privileges
what is the error?Hello Andrew,
Thanks for your reply, after granting the necessary priviliges i executed the query again this time i got the following error
SQL> CREATE MATERIALIZED VIEW system_active_loss_mv
2 BUILD IMMEDIATE
3 REFRESH FAST ON COMMIT
4 ENABLE QUERY REWRITE
5 AS
6 SELECT zone_name,
7 EXTRACT(YEAR FROM active_loss_datetime)|| EXTRACT(MONTH FROM active_loss_datetime) as
active_loss_period,
8 count(*) ,
9 count(active_qloss),
10 SUM(active_qloss) as active_qloss,
11 SUM(active_ploss) as active_ploss,
12 SUM(active_gain) as active_gain
13 FROM system_active_loss_day
14 GROUP BY zone_name,
15 EXTRACT(YEAR FROM active_loss_datetime),
16 EXTRACT(MONTH FROM active_loss_datetime);
FROM system_active_loss_day
ERROR at line 13:
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
when i removed the 'REFRESH FAST ON COMMIT' from above query the view has created...but we want this to be refreshed everytime we insert a new record in the base table. -
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.
-
Create materialized view with ora-12054 error
Oracle 10g R2 on AIX 5.3L
I create a script (with help of EM) for a materilaized view
CREATE MATERIALIZED VIEW "BAANDB"."R2_MV"
TABLESPACE "USERS" NOLOGGING STORAGE ( INITIAL 128K) USING INDEX TABLESPACE "BAANIDX" STORAGE ( INITIAL 256K)
REFRESH FORCE ON COMMIT
ENABLE QUERY REWRITE AS
SELECT CM.ROWID c_rid, PC.ROWID p_rid, CM."T$CWOC", "T$EMNO", CM."T$NAMA", CM."T$EDTE", PC."T$PERI", PC."T$QUAN", PC."T$YEAR", PC."T$RGDT" From BAANDB.TTPPPC235201 PC RIGHT OUTER JOIN BAANDB.TTCCOM001201 CM Using (T$EMNO)
but I got error
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
acooding to the oerr
// *Cause: The materialized view did not satisfy conditions for refresh at
// commit time.
// *Action: Specify only valid options.
what dose it mean? both my master tables are not IOT and are locale ones. It seems that only changing to ON DEMAND works. If I use the "REFRESH FORCE START ..NEXT", it also failed.
I have created the materalized view logs with rowid on each master table. I think my script met every prequirement of ON COMMIT.
table owner has "on commit refresh" privilegeAfter googling on line, someone mentioned that for "ON COMMIT" on join tables, we have to use th old OUTER JOINT syntax (+) on WHERE. The new "outer joint" in FROM clause won't work.
I tested it, it seemed to be true.
Maybe you are looking for
-
My ipod touch is not recognized by itunes on my laptop.
My ipod touch is not recognized by itunes on my laptop, it has windows 7. I have already done the troubleshoot process and the "msconfig" process as well. What could be wrong?
-
I want to put Linux in my iPod but I need to "unUpdate" it to v 1.0 (its updated to 1.2 right now). I tried alot of stuff but never works... I got the 20gb iPod photo (the generation just before Video iPod) When I use "restore", my iPod stay at V1.2
-
Invalid Syntax error while using Ant and WLST
I am trying to run the following code in an ant build file but continue to see the error below even though the exact same code works through the WLST console. Any help would be greatly appreciated. Note: * = 1 tab <wlst debug="true" failonerror="fals
-
Hi All, I am trying to load text data into Essbase using a rule file but it gives me this error \\ Invalid number in data column Is there any other way to load text? Appreciate your help Best Regards
-
I blocked my ¡phone 4 because i don't remember the password
i just can't remember my password