Good morning,
I'm trying to do an update on a column using information from another table using ORACLE. However, I'm getting the error "ORA-01779: Can not modify a column that maps a table not preserved by the key."
Following script used:
update (
select AP.NR_ATENDIMENTO,
PPR.NR_PRESCRICAO,
PP.CD_MEDICO_EXECUTOR,
PP.CD_FUNCAO,
PPR.CD_MEDICO_EXEC,
PPR.NR_SEQUENCIA,
PP.NR_INTERNO_CONTA,
lp.CD_MEDICO_RESP
from atendimento_paciente ap
inner join PRESCR_MEDICA pm on
AP.NR_ATENDIMENTO = PM.NR_ATENDIMENTO
INNER JOIN PRESCR_PROCEDIMENTO PPR ON
PM.NR_PRESCRICAO = PPR.NR_PRESCRICAO
INNER JOIN PROCEDIMENTO_PACIENTE PP ON
PPR.NR_PRESCRICAO = PP.NR_PRESCRICAO
AND PPR.NR_SEQUENCIA = PP.NR_SEQUENCIA_PRESCRICAO
LEFT JOIN LAUDO_PACIENTE LP ON
PPR.NR_PRESCRICAO = LP.NR_PRESCRICAO
AND PPR.NR_SEQUENCIA = LP.NR_SEQ_PRESCRICAO
WHERE 0 = 0
and PPR.CD_MEDICO_EXEC is not null
and PP.CD_MEDICO_EXECUTOR IS NULL
AND PPR.CD_SETOR_ATENDIMENTO <> 78
AND PP.NR_INTERNO_CONTA IS NOT NULL
AND AP.DT_ENTRADA >= '01/04/2018'
AND PP.CD_FUNCAO <> 900
and AP.NR_ATENDIMENTO = 297106
AND LP.CD_MEDICO_RESP IS NOT NULL
) Updt set Updt.CD_MEDICO_EXECUTOR = Updt.CD_MEDICO_RESP; commit;
Does anyone have a tip on how to do this update?
atte;