[英]Join 3 tables to update and insert
我正在嘗試從 3 個表(B69_CAT_ALERTA_FILE、TBL_INTERLOCUTORES 和 B69_TBL_ALERTA 警報)中插入和更新數據到 B69_TBL_ALERTA_CONCENTRADO 集中器。 使用 2 INNER JOIN 它可以工作,但是將第三個表添加到它會失敗。 它說無效的標識符 ID_ALERTA。 插入和更新不是問題,這就是我不添加該代碼的原因。
MERGE INTO B69_TBL_ALERTA_CONCENTRADO concentrado USING (
SELECT
inter.rfc as inter_rfc,
alerta.id_alerta,
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_INTERLOCUTORES inter ON inter.rfc = archivo.rfc
INNER JOIN B69_TBL_ALERTA alerta ON concentrado.id_alerta = alerta.id_alerta
) v_using ON (concentrado.rfc = v_using.rfc)
錯誤
錯誤():PL / SQL:ORA-00904:“CONCENTRADO”。 “ID_ALERTA”:無效標識符
做
SELECT 1 FROM B69_TBL_ALERTA_CONCENTRADO concentrado JOIN (
SELECT
inter.rfc as inter_rfc,
alerta.id_alerta,
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_INTERLOCUTORES inter ON inter.rfc = archivo.rfc
INNER JOIN B69_TBL_ALERTA alerta ON concentrado.id_alerta = alerta.id_alerta
) v_using ON (concentrado.rfc = v_using.rfc);
如果是錯誤的,你有匹配表的問題,如果不是,你有 MERGE 的問題。
請試試這個
MERGE INTO B69_TBL_ALERTA_CONCENTRADO concentrado USING (
SELECT
inter.rfc as inter_rfc,
alerta.id_alerta,
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_INTERLOCUTORES inter ON inter.rfc = archivo.rfc
INNER JOIN B69_TBL_ALERTA alerta ON alerta.id_alerta = inter.rfc
) v_using ON (concentrado.rfc = v_using.rfc and concentrado.id_alerta = v_using.id_alerta)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.