| Update multiple rows with multi join [message #645390] |
Fri, 04 December 2015 16:53  |
 |
gorants
Messages: 85 Registered: May 2014 Location: ATL
|
Member |
|
|
Team,
I am using below query to update values in table which has multiple joins but i am getting errors.
query :
update (select vpt.dor_mas_id as vpt_id , vm.dor_mas_id as vm_id from ven_pe_tr vpt
join gpn l on vpt.case_nbr = l.tc_gpn_id
join ven_ma vm on l.business_partner_id = vm.vendor_id
where
vpt.stat_code = '10'
and vpt.dor_mas_id <> vm.dor_mas_id) set vpt_id=vm_id;
Errors:
Error report -
SQL Error: ORA-01779: cannot modify a column which maps to a non key-preserved table
01779. 00000 - "cannot modify a column which maps to a non key-preserved table"
*Cause: An attempt was made to insert or update columns of a join view which
map to a non-key-preserved table.
*Action: Modify the underlying base tables directly.
Can someone please guide me on this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Update multiple rows with multi join [message #645399 is a reply to message #645398] |
Fri, 04 December 2015 18:26   |
 |
gorants
Messages: 85 Registered: May 2014 Location: ATL
|
Member |
|
|
ok, I am trying to update dor_mas_id in ven_pe_tr table with values captured in i but after update i am not seeing vpt.dor_mas_id = vm.dor_mas_id. Am i missing anything here. Sure i will provide all tables with data, just incase if anything obviously looking wrong.
set serveroutput on;
BEGIN
For i in (select vpt.dor_mas_id as vpt_id , vm.dor_mas_id as vm_id from ven_pe_tr vpt
join gpn l on vpt.case_nbr = l.tc_gpn_id
join ven_ma vm on l.business_partner_id = vm.vendor_id
where
vpt.stat_code = '10'
and vpt.dor_mas_id <> vm.dor_mas_id)
LOOP
update ven_pe_tr set dor_mas_id = i.vm_id where dor_mas_id = i.vpt_id;
END LOOP;
END;
[Updated on: Fri, 04 December 2015 18:27] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|