0
Good morning,
I am trying to update a column using information from another table using ORACLE. However, I am receiving the error "ORA-01779: it is not possible to modify a column that changes 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;
Someone has a tip on how to do this update?
Atte;
Use Merge: http://www.oratable.com/oracle-merge-command-for-upsert/
– William John Adam Trindade