Reputation: 1
In oracle, trying to update a column in the same table - like if the column has value 636180 then with 3 as below
update TABLE_A
set wid = (
select distinct case wid
when 636180 then 3
when 636181 then 5
else wid
end new_wid
from TABLE_A where rownum < 100);
It errors out as
SQL Error: ORA-01427: single-row subquery returns more than one row
01427. 00000 - "single-row subquery returns more than one row"
Please help.
Upvotes: 0
Views: 1158
Reputation: 204766
update TABLE_A
set wid = case when wid = 636180 then 3
when wid = 636181 then 5
else wid
end
where rownum < 100
or to only update the records having the relevant wid
s
update TABLE_A
set wid = case when wid = 636180 then 3
when wid = 636181 then 5
end
where wid in (636180, 636181)
Upvotes: 1