ORA-30926: 无法在源表中获得稳定的行集
ORA-30926: unable to get stable rowset in source tables
我尝试执行合并,但是,它不允许我,我已经添加了 DISTINCT,清除了要更新的字段,并且在 USING 函数中它们是唯一的字段,它们不重复,每个都有不同的信息,值得一提的是,我要插入或更新数据的table已经存在
MERGE INTO B69_TBL_ALERTA_CONCENTRADO concentrado
USING (SELECT DISTINCT
archivo.id_archivo,archivo.rfc, archivo.nombre_contribuyente , archivo.situacion_contribuyente ,
archivo.oficio_global, archivo.publicacion_presuntos , archivo.publicacion_definitivos
FROM B69_CAT_ALERTA_ARCHIVO archivo
INNER JOIN TBL_TRANSACCIONES txn
ON txn.titular = archivo.nombre_contribuyente)v_using
ON (concentrado.nombre_contribuyente = v_using.nombre_contribuyente)
WHEN MATCHED THEN
UPDATE SET
concentrado.id_archivo = v_using.id_archivo,
concentrado.snapshot_date = DATE '2021-06-16',
concentrado.rfc = v_using.rfc,
concentrado.situacion_contribuyente = v_using.situacion_contribuyente,
concentrado.oficio_global = v_using.oficio_global,
concentrado.publicacion_presuntos = v_using.publicacion_presuntos,
concentrado.publicacion_definitivos = v_using.publicacion_definitivos,
concentrado.last_update = CURRENT_DATE,
concentrado.id_alertatipo = 2
WHEN NOT MATCHED THEN
INSERT (concentrado.id_concentrado,concentrado.id_archivo,concentrado.snapshot_date,concentrado.rfc,concentrado.nombre_contribuyente,
concentrado.situacion_contribuyente,concentrado.oficio_global,concentrado.publicacion_presuntos,
concentrado.publicacion_definitivos,concentrado.baja_logica,concentrado.last_update,concentrado.id_alertatipo)
VALUES (b69id_gralaut.nextval,v_using.id_archivo,DATE '2021-06-16',v_using.rfc,v_using.nombre_contribuyente,
v_using.situacion_contribuyente,v_using.oficio_global,v_using.publicacion_presuntos,
v_using.publicacion_definitivos,'0',CURRENT_DATE,'2');
COMMIT;
END STP_69B_ALERTA_EXTERNA;
我收到以下错误:
Connecting to the Alerts database.
ORA-30926: unable to get stable rowset in source tables
ORA-06512: in "CDO_ALERTAS.STP_69B_ALERTA_EXTERNA", line 4
ORA-06512: online 2
The process is over.
Disconnecting from the Alerts database.
您的问题 - using
子查询在键 nombre_contribuyente
中产生重复的行
检查
with v_using as (SELECT DISTINCT
archivo.id_archivo,archivo.rfc, archivo.nombre_contribuyente , archivo.situacion_contribuyente ,
archivo.oficio_global, archivo.publicacion_presuntos , archivo.publicacion_definitivos
FROM B69_CAT_ALERTA_ARCHIVO archivo
INNER JOIN TBL_TRANSACCIONES txn
ON txn.titular = archivo.nombre_contribuyente)
select nombre_contribuyente, count(*)
from v_using
group by nombre_contribuyente
order by 2 desc;
在结果的顶部,您会看到计数 > 1 的键
您必须重新构造 using
子查询,以便合并的连接键是唯一的 - Distinct
是不够的,您必须使用例如GROUP BY
在键上。
我尝试执行合并,但是,它不允许我,我已经添加了 DISTINCT,清除了要更新的字段,并且在 USING 函数中它们是唯一的字段,它们不重复,每个都有不同的信息,值得一提的是,我要插入或更新数据的table已经存在
MERGE INTO B69_TBL_ALERTA_CONCENTRADO concentrado
USING (SELECT DISTINCT
archivo.id_archivo,archivo.rfc, archivo.nombre_contribuyente , archivo.situacion_contribuyente ,
archivo.oficio_global, archivo.publicacion_presuntos , archivo.publicacion_definitivos
FROM B69_CAT_ALERTA_ARCHIVO archivo
INNER JOIN TBL_TRANSACCIONES txn
ON txn.titular = archivo.nombre_contribuyente)v_using
ON (concentrado.nombre_contribuyente = v_using.nombre_contribuyente)
WHEN MATCHED THEN
UPDATE SET
concentrado.id_archivo = v_using.id_archivo,
concentrado.snapshot_date = DATE '2021-06-16',
concentrado.rfc = v_using.rfc,
concentrado.situacion_contribuyente = v_using.situacion_contribuyente,
concentrado.oficio_global = v_using.oficio_global,
concentrado.publicacion_presuntos = v_using.publicacion_presuntos,
concentrado.publicacion_definitivos = v_using.publicacion_definitivos,
concentrado.last_update = CURRENT_DATE,
concentrado.id_alertatipo = 2
WHEN NOT MATCHED THEN
INSERT (concentrado.id_concentrado,concentrado.id_archivo,concentrado.snapshot_date,concentrado.rfc,concentrado.nombre_contribuyente,
concentrado.situacion_contribuyente,concentrado.oficio_global,concentrado.publicacion_presuntos,
concentrado.publicacion_definitivos,concentrado.baja_logica,concentrado.last_update,concentrado.id_alertatipo)
VALUES (b69id_gralaut.nextval,v_using.id_archivo,DATE '2021-06-16',v_using.rfc,v_using.nombre_contribuyente,
v_using.situacion_contribuyente,v_using.oficio_global,v_using.publicacion_presuntos,
v_using.publicacion_definitivos,'0',CURRENT_DATE,'2');
COMMIT;
END STP_69B_ALERTA_EXTERNA;
我收到以下错误:
Connecting to the Alerts database.
ORA-30926: unable to get stable rowset in source tables
ORA-06512: in "CDO_ALERTAS.STP_69B_ALERTA_EXTERNA", line 4
ORA-06512: online 2
The process is over.
Disconnecting from the Alerts database.
您的问题 - using
子查询在键 nombre_contribuyente
检查
with v_using as (SELECT DISTINCT
archivo.id_archivo,archivo.rfc, archivo.nombre_contribuyente , archivo.situacion_contribuyente ,
archivo.oficio_global, archivo.publicacion_presuntos , archivo.publicacion_definitivos
FROM B69_CAT_ALERTA_ARCHIVO archivo
INNER JOIN TBL_TRANSACCIONES txn
ON txn.titular = archivo.nombre_contribuyente)
select nombre_contribuyente, count(*)
from v_using
group by nombre_contribuyente
order by 2 desc;
在结果的顶部,您会看到计数 > 1 的键
您必须重新构造 using
子查询,以便合并的连接键是唯一的 - Distinct
是不够的,您必须使用例如GROUP BY
在键上。