Hi. I´m trying to refresh complete of a MV with this code:
Error que empieza en la línea: 1 del comando :
BEGIN
k36_gestiona_bi_ventas.p_refrescar_mv('MV36_VENTA_CLIENTE');
END;
Informe de error -
ORA-12008: error en la ruta de refrescamiento del mapa de zona o de la vista materializada
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 3238
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 2620
ORA-00904: "A2"."PRD_ID_PRODUCTO": identificador no válido
ORA-02063: line precediendo a PROD
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 91
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 288
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 2601
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 3194
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 3481
ORA-06512: en "SYS.DBMS_SNAPSHOT_KKXRCA", línea 3513
ORA-06512: en "SYS.DBMS_SNAPSHOT", línea 16
ORA-06512: en "BIFIGO.K36_GESTIONA_BI_VENTAS", línea 25
ORA-06512: en línea 2
12008. 00000 - "error in materialized view or zonemap refresh path"
*Cause: Table SNAP$_<mview_name> reads rows from the view
MVIEW$_<mview_name>, which is a view on the master table
(the master may be at a remote site). Any
error in this path will cause this error at refresh time.
For fast refreshes, the table <master_owner>.MLOG$_<master>
is also referenced.
*Action: Examine the other messages on the stack to find the problem.
See if the objects SNAP$_<mview_name>, MVIEW$_<mview_name>,
<mowner>.<master>@<dblink>, <mowner>.MLOG$_<master>@<dblink>
still exist.
I have identified where error ocurrs:
CREATE MATERIALIZED VIEW "BIFIGO"."MV36_VENTA_CLIENTE" ("CO_PERIODO_EJERCICIO", "NB_PERIODO_EJERCICIO", "CO_EMPRESA", "NB_EMPRESA", "CO_SUCURSAL_EMPRESA", "CO_CLIENTE", "NB_CLIENTE", "NB_CLIENTE_ABREVIADO", "CO_CLASE_CLIENTE", "DE_CLASE_CLIENTE", "CO_ZONA_VENTA", "DE_ZONA_VENTA", "CO_SUCURSAL_CLIENTE", "NB_SUCURSAL_CLIENTE", "CO_UBICACION_GEOGRAFICA", "NB_UBICACION_GEOGRAFICA", "NB_UBG_ABREVIADO", "VA_LATITUD", "VA_LONGITUD", "CO_MONEDA", "DE_MONEDA", "CO_UNIDAD_MEDIDA", "DE_UNIDAD_MEDIDA", "CA_FRECUENCIA_TRANSACCION", "FE_ULTIMA_TRANSACCION", "CA_PRODUCTO", "MN_PRODUCTO", "PR_COSTO_PRODUCTO", "PR_PRODUCTO", "PR_DESCUENTO_PRODUCTO")
SEGMENT CREATION IMMEDIATE
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX
REFRESH FORCE ON DEMAND
USING DEFAULT LOCAL ROLLBACK SEGMENT
USING ENFORCED CONSTRAINTS DISABLE ON QUERY COMPUTATION DISABLE QUERY REWRITE
AS select to_char(pej.fe_inicio_periodo,'YYYY-MM') co_periodo_ejercicio
,pej.nb_periodo_ejercicio
,emp.co_empresa
,emp.nb_empresa
,esu.co_sucursal co_sucursal_empresa
,emo.co_organizacion co_cliente
,org.nb_organizacion nb_cliente
,org.nb_abreviado_organizacion nb_cliente_abreviado
,clc.co_ocurrencia co_clase_cliente
,clc.de_ocurrencia de_clase_cliente
,zdi.co_ocurrencia co_zona_venta
,zdi.de_ocurrencia de_zona_venta
,suc.co_sucursal co_sucursal_cliente
,suc.nb_sucursal nb_sucursal_cliente
,nvl(ugs.co_ubicacion
,ubg.co_ubicacion) co_ubicacion_geografica
,nvl(ugs.nb_ubicacion
,ubg.nb_ubicacion) nb_ubicacion_geografica
,nvl(ugs.nb_ubicacion_abreviado
,ubg.nb_ubicacion_abreviado) nb_ubg_abreviado
,nvl(ugs.va_latitud
,ubg.va_latitud) va_latitud
,nvl(ugs.va_longitud
,ubg.va_longitud) va_longitud
,mon.co_unidad_medida co_moneda
,mon.de_unidad_medida de_moneda
,unm.co_unidad_medida
,unm.de_unidad_medida
,count(distinct nos.id_registro) ca_frecuencia_transaccion
,max(nos.fe_emision) fe_ultima_transaccion
,sum(nsp.ca_producto) ca_producto
,sum((nsp.pr_producto
- nvl(nsp.pr_descuento_producto,0))
* nsp.ca_producto) mn_producto
,avg(nsp.pr_costo_producto) pr_costo_producto
,avg(nsp.pr_producto) pr_producto
,avg(nsp.pr_descuento_producto) pr_descuento_producto
from t00_empresa emp
,t03_empresa_sucursal esu
,t01_ejercicio_contable ejc
,t01_periodo_ejercicio pej
,t00_empresa_organizacion emo
,t00_organizacion org
,t00_contenido_tabla_virtual clc
,t00_contenido_tabla_virtual zdi
,t03_organizacion_sucursal suc
,t00_ubicacion_geografica ubg
,t00_ubicacion_geografica ugs
,t03_nota_salida nos
,t03_nota_salida_producto nsp
,t00_unidad_medida mon
,t00_unidad_medida unm
where esu.emp_id_empresa (+) = emp.id_registro
and emp.id_registro = ejc.emp_id_empresa
and ejc.id_registro = pej.ejc_id_ejercicio
and emp.id_registro = emo.emp_id_empresa
and org.id_registro = emo.org_id_organizacion
and ubg.id_registro = org.ubg_id_ubicacion
and clc.id_registro = emo.ctv_id_clase_organizacion
and zdi.id_registro (+) = org.ctv_id_zona_distribucion
and emo.ctv_id_tipo_relacion = (select id_registro
from t00_contenido_tabla_virtual trc
where trc.id_registro = emo.ctv_id_tipo_relacion
and trc.co_ocurrencia = (select va_texto_variable
from t00_variable_control
where emp_id_empresa = emp.id_registro
and co_variable_control = 'CO_TIPO_RELACION_CLIENTE')
)
and nos.emp_id_empresa = emp.id_registro
and nos.org_id_organizacion = org.id_registro
and suc.id_registro (+) = nos.ors_id_sucursal
and ugs.id_registro (+) = suc.ubg_id_ubicacion_geografica
and nos.id_registro = nsp.nos_id_nota_salida
and mon.id_registro = nos.unm_id_unidad_monetaria
and unm.id_registro = nsp.unm_id_unidad_medida
and nos.fac_id_factura is null
and nos.fe_emision between pej.fe_inicio_periodo
and pej.fe_fin_periodo
and exists (select 1
from t00_relacion_tabla
where nb_tabla_padre = 'S00_PROCESO'
and id_referencia_tabla_padre in (select id_registro
from t00_proceso
where co_proceso= 'SFIGO03F008'
union all
select id_registro
from t00_proceso
where co_proceso='SFIGO15F001'
union all
select id_registro
from t00_proceso
where co_proceso='SFIGO05F017'
)
and nb_tabla_hija = 'TIPO_DOCUMENTO'
and id_referencia_tabla_hija = nos.ctv_id_tipo_documento)
and nos.ctv_id_motivo_salida in (select id_registro
from t00_contenido_tabla_virtual mos
where mos.emp_id_empresa = emp.id_registro
and mos.tvr_nb_tabla = 'MOTIVO_DOCUMENTO'
start with mos.id_registro = (select id_registro
from t00_contenido_tabla_virtual mot
where mot.emp_id_empresa = emp.id_registro
and mot.tvr_nb_tabla = 'MOTIVO_DOCUMENTO'
and mot.co_ocurrencia = (select va_texto_variable
from t00_variable_control rel
where rel.emp_id_empresa = emp.id_registro
and co_variable_control ='CO_MOTIVO_NOS_VENTA')
)
connect by prior mos.id_registro = mos.ctv_id_ocurrencia_padre)
and exists (select 1
from t00_contenido_tabla_virtual
where id_registro = nos.ctv_id_estado_documento
and co_ocurrencia != (select va_texto_variable
from t00_variable_control eda
where eda.emp_id_empresa = emp.id_registro
and co_variable_control ='CO_ESTADO_DOCUMENTO_ANULADO')
)
group by to_char(pej.fe_inicio_periodo,'YYYY-MM')
,pej.nb_periodo_ejercicio
,emp.co_empresa
,emp.nb_empresa
,esu.co_sucursal
,emo.co_organizacion
,org.nb_organizacion
,org.nb_abreviado_organizacion
,clc.co_ocurrencia
,clc.de_ocurrencia
,zdi.co_ocurrencia
,zdi.de_ocurrencia
,suc.co_sucursal
,suc.nb_sucursal
,nvl(ugs.co_ubicacion
,ubg.co_ubicacion)
,nvl(ugs.nb_ubicacion
,ubg.nb_ubicacion)
,nvl(ugs.nb_ubicacion_abreviado
,ubg.nb_ubicacion_abreviado)
,nvl(ugs.va_latitud
,ubg.va_latitud)
,nvl(ugs.va_longitud
,ubg.va_longitud)
,mon.co_unidad_medida
,mon.de_unidad_medida
,unm.co_unidad_medida
,unm.de_unidad_medida
--
union all
--
-- FACTURAS DE VENTAS
--
select to_char(pej.fe_inicio_periodo,'YYYY-MM') co_periodo_ejercicio
,pej.nb_periodo_ejercicio
,emp.co_empresa
,emp.nb_empresa
,esu.co_sucursal co_sucursal_empresa
,emo.co_organizacion co_cliente
,org.nb_organizacion nb_cliente
,org.nb_abreviado_organizacion nb_cliente_abreviado
,clc.co_ocurrencia co_clase_cliente
,clc.de_ocurrencia de_clase_cliente
,zdi.co_ocurrencia co_zona_venta
,zdi.de_ocurrencia de_zona_venta
,suc.co_sucursal co_sucursal_cliente
,suc.nb_sucursal nb_sucursal_cliente
,nvl(ugs.co_ubicacion
,ubg.co_ubicacion) co_ubicacion_geografica
,nvl(ugs.nb_ubicacion
,ubg.nb_ubicacion) nb_ubicacion_geografica
,nvl(ugs.nb_ubicacion_abreviado
,ubg.nb_ubicacion_abreviado) nb_ubg_abreviado
,nvl(ugs.va_latitud
,ubg.va_latitud) va_latitud
,nvl(ugs.va_longitud
,ubg.va_longitud) va_longitud
,mon.co_unidad_medida co_moneda
,mon.de_unidad_medida de_moneda
,unm.co_unidad_medida
,unm.de_unidad_medida
,count(distinct fac.id_registro) ca_frecuencia_transaccion
,max(fac.fe_emision) fe_ultima_transaccion
,sum(fap.ca_producto) ca_producto
,sum((fap.pr_producto
- nvl(fap.pr_descuento_producto,0))
* fap.ca_producto) mn_producto
,avg((select avg(nsp.pr_costo_producto)
from t03_nota_salida nos
,t03_nota_salida_producto nsp
where nos.fac_id_factura = fap.fac_id_factura
and nsp.nos_id_nota_salida = nos.id_registro
and nsp.prd_id_producto = fap.prd_id_producto)) pr_costo_producto
,avg(fap.pr_producto) pr_producto
,avg(fap.pr_descuento_producto) pr_descuento_producto
from t00_empresa emp
,t03_empresa_sucursal esu
,t01_ejercicio_contable ejc
,t01_periodo_ejercicio pej
,t00_empresa_organizacion emo
,t00_organizacion org
,t00_contenido_tabla_virtual clc
,t00_contenido_tabla_virtual zdi
,t03_organizacion_sucursal suc
,t00_ubicacion_geografica ubg
,t00_ubicacion_geografica ugs
,t04_factura fac
,t00_unidad_medida mon
,t04_factura_producto fap
,t00_unidad_medida unm
where esu.emp_id_empresa (+) = emp.id_registro
and emp.id_registro = ejc.emp_id_empresa
and ejc.id_registro = pej.ejc_id_ejercicio
and emp.id_registro = emo.emp_id_empresa
and org.id_registro = emo.org_id_organizacion
and ubg.id_registro = org.ubg_id_ubicacion
and clc.id_registro = emo.ctv_id_clase_organizacion
and zdi.id_registro (+) = org.ctv_id_zona_distribucion
and emo.ctv_id_tipo_relacion = (select id_registro
from t00_contenido_tabla_virtual trc
where trc.id_registro = emo.ctv_id_tipo_relacion
and trc.co_ocurrencia = (select va_texto_variable
from t00_variable_control
where emp_id_empresa = emp.id_registro
and co_variable_control = 'CO_TIPO_RELACION_CLIENTE')
)
and fac.emp_id_empresa = emp.id_registro
and fac.fe_emision between pej.fe_inicio_periodo
and pej.fe_fin_periodo
and fac.id_registro = fap.fac_id_factura
and fac.org_id_organizacion = org.id_registro
and suc.id_registro (+) = fac.ors_id_sucursal
and ugs.id_registro (+) = suc.ubg_id_ubicacion_geografica
and mon.id_registro = fac.unm_id_unidad_monetaria
and unm.id_registro = fap.unm_id_unidad_medida
and exists (select 1
from t00_contenido_tabla_virtual
where id_registro = fac.ctv_id_estado_documento
and co_ocurrencia != (select va_texto_variable
from t00_variable_control tdo
where tdo.emp_id_empresa = emp.id_registro
and co_variable_control ='CO_TIPO_DOCUMENTO_FACTURA_CLIENTE')
)
and exists (select 1
from t00_contenido_tabla_virtual
where id_registro = fac.ctv_id_estado_documento
and co_ocurrencia != (select va_texto_variable
from t00_variable_control eda
where eda.emp_id_empresa = emp.id_registro
and co_variable_control ='CO_ESTADO_DOCUMENTO_ANULADO')
)
group by to_char(pej.fe_inicio_periodo,'YYYY-MM')
,pej.nb_periodo_ejercicio
,emp.co_empresa
,emp.nb_empresa
,esu.co_sucursal
,emo.co_organizacion
,org.nb_organizacion
,org.nb_abreviado_organizacion
,clc.co_ocurrencia
,clc.de_ocurrencia
,zdi.co_ocurrencia
,zdi.de_ocurrencia
,suc.co_sucursal
,suc.nb_sucursal
,nvl(ugs.co_ubicacion
,ubg.co_ubicacion)
,nvl(ugs.nb_ubicacion
,ubg.nb_ubicacion)
,nvl(ugs.nb_ubicacion_abreviado
,ubg.nb_ubicacion_abreviado)
,nvl(ugs.va_latitud
,ubg.va_latitud)
,nvl(ugs.va_longitud
,ubg.va_longitud)
,mon.co_unidad_medida
,mon.de_unidad_medida
,unm.co_unidad_medida
,unm.de_unidad_medida
--
Error ir this portion of code:
,avg((select avg(nsp.pr_costo_producto)
from t03_nota_salida nos
,t03_nota_salida_producto nsp
where nos.fac_id_factura = fap.fac_id_factura
and nsp.nos_id_nota_salida = nos.id_registro
and nsp.prd_id_producto = fap.prd_id_producto)) pr_costo_producto
I recreated this view putting 0 instead of subquery and i was able to refresh.
Also if I recreate the MV no issues.
Is this a bug? I´m testing with XE 21c.
Thanks so much in advance!