ORA-01427: single-row subquery returns more than one row in update statement
Hi. For below query, ORA-01427 error occurred.
I'm trying to get birthday from country_population and set it as fave_date in city_population. Other simpler way to execute this is not needed, I just need some suggestion how to eliminate the error and let the query work. Thank you :)
DECLARE
CURSOR custCur IS
SELECT name, age, weight, height, birthday FROM country_population;
CNTR number(9) := 0;
BEGIN
FOR curRec IN custCur LOOP
UPDATE city_population srvagr
SET srvagr.date1 = SYSDATE,
srvagr.fave_date =
(select curRec.birthday from country_population curRec
where srvagr.name=curRec.name
and srvagr.age=curRec.age
and srvagr.weight=curRec.weight
and srvagr.height=curRec.height),
srvagr.date2 = SYSDATE,
srvagr.date3 = SYSDATE,
srvagr.status = 'visitor',
srvagr.note = 'Noted'
WHERE
srvagr.name = curRec.name
and srvagr.age = curRec.age
and srvagr.weight = curRec.weight
and srvagr.height = curRec.height
and srvagr.status != 'visitor'
and srvagr.fave_date is null;
CNTR := CNTR + 1;
if CNTR = 1000
then
COMMIT;
CNTR := 0;
end if;
END LOOP;
COMMIT;