Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Update statement

Status
Not open for further replies.

cuetzpalin

Programmer
Jun 5, 2002
99
US
I have 2 tables:
p2p_transfer_in_upd
el_transfer_in_upd_temp

I need to update the p2p_transfer_in_upd table based on some values in the el_transfer_in_upd_temp table (see code).

I'm getting the following error:
(0RA01427; single row subquery returns more than one row)

Code:
update p2p_transfer_in_upd
set enrollment_date = (select enrollment_date
			from el_transfer_in_upd_temp
			where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
	,mrn		= (select mrn
			from el_transfer_in_upd_temp
			where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
	,region_id	= (select region_id
			from el_transfer_in_upd_temp
			where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
where exists (select 'x' from   el_transfer_in_upd_temp
		where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
	and     p2p_transfer_in_upd.ht_load_complete_dt is null

I don't know what the problem is. Please help me.

Thank you.
 
Either
Code:
(select enrollment_date
            from el_transfer_in_upd_temp
            where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
or
Code:
(select region_id
            from el_transfer_in_upd_temp
            where p2p_transfer_in_upd.hicn = el_transfer_in_upd_temp.hicn)
is returning more than one row. The "=" rather than "exists" demands that only one row be returned in your sub-query.

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top