baimWonk
baimWonk

Reputation: 841

Update Table Error: cannot modify a column which maps to a non key-preserved table

I have a query just like this:

UPDATE 
(SELECT STATUS, T_ID FROM FINANCE.RKAP_RENCANA a 
    LEFT JOIN FINANCE.RKAP_MASTER_KODE b ON b.ID_KODE = a.KODE_ANGGARAN 
    WHERE a.TAHUN = '2018' AND b.KET_KD_GAS = 'BSI') t1 
SET t1.STATUS = '1', t1.T_ID = '5d81a2b1d36a1'

I wish to make update Status and ID_Kode become 1 and 5d81a2b1d36a1, but this error code always appears

ORA-01779: cannot modify a column which maps to a non-key-preserved table

I've been work with:

update finance.rkap_rencana set status = '1', t_id = '5d81a2b1d36a1'

But, it's not what I want.

Does anyone know how to do this?

Thanks

Upvotes: 0

Views: 141

Answers (1)

Rustam Pulatov
Rustam Pulatov

Reputation: 665

If I you understand rigth:

UPDATE FINANCE.RKAP_RENCANA a SET a.STATUS = '1', a.T_ID = '5d81a2b1d36a1'
WHERE a.TAHUN = '2018'
    AND EXISTS (SELECT 1 FROM FINANCE.RKAP_MASTER_KODE b
    WHERE b.ID_KODE = a.KODE_ANGGARAN
    AND b.KET_KD_GAS = 'BSI')

Upvotes: 1

Related Questions