Can anyone tell me how to do this in Oracle?
This is not the exact query but I wanted to simplify it a little. The problem I see is that the WHERE clause depends on the join which I cannot do in Oracle.
------ A
update table1 t1
set t1.pdesc=t2.pde sc, t1.pcost=t3.pco st
from table1 t1 left outer join table2 t2 on t1.name=t2.name
left outer join table3 t3 on t2.product=t3.p roduct
where t1.site='MD' and t1.pdesc is null and t2.pdesc is not null and t1.pcost is null and t3.pcost is not null
------ A
When I try this code below, I get :
ORA-01427: single-row subquery returns more than one row.
------ B
update table1 t1
set (t1.pdesc, t1.pcost)=
(select t2.pdesc, t3.pcost
from table1 t1 left outer join table2 t2 on t1.name=t2.name
left outer join table3 t3 on t2.product=t3.p roduct
where t1.site='MD' and t1.pdesc is null and t2.pdesc is not null
and t1.pcost is null and t3.pcost is not null)
------ B
There will be multiple rows of the same name and product combination but each name and product will only have one pdesc and pcost value.
Thank you!
drahmani
This is not the exact query but I wanted to simplify it a little. The problem I see is that the WHERE clause depends on the join which I cannot do in Oracle.
------ A
update table1 t1
set t1.pdesc=t2.pde sc, t1.pcost=t3.pco st
from table1 t1 left outer join table2 t2 on t1.name=t2.name
left outer join table3 t3 on t2.product=t3.p roduct
where t1.site='MD' and t1.pdesc is null and t2.pdesc is not null and t1.pcost is null and t3.pcost is not null
------ A
When I try this code below, I get :
ORA-01427: single-row subquery returns more than one row.
------ B
update table1 t1
set (t1.pdesc, t1.pcost)=
(select t2.pdesc, t3.pcost
from table1 t1 left outer join table2 t2 on t1.name=t2.name
left outer join table3 t3 on t2.product=t3.p roduct
where t1.site='MD' and t1.pdesc is null and t2.pdesc is not null
and t1.pcost is null and t3.pcost is not null)
------ B
There will be multiple rows of the same name and product combination but each name and product will only have one pdesc and pcost value.
Thank you!
drahmani
Comment