Re: multiple values updates

From: L. Scott Johnson <lscott_at_crl.com>
Date: 15 Jun 1994 16:48:07 -0700
Message-ID: <2to3vn$iud_at_crl2.crl.com>


In article <29172_at_dciem.dciem.dnd.ca>, Selina Glynn <selina_at_dciem.dnd.ca> wrote:
>I need to update a field from the values of another table. I have written
>a similar update statement before, it used to work now its complains:
>
>SQL> update divername
> 2 set file_no =
> 3 (select b.fn
> 4 from divername a, pers_info b
> 5 where a.last_name = b.lastn
> 6 and a.first_name = b.firstn)
> 7 /
>(select b.fn
> *
>ERROR at line 3:
>ORA-01427: single-row subquery returns more than one row
>
You subquery is specific enough, or you've simply got som redundant data in the divername, pers_info table(s). One way to circumvent the error is to select max(b.fn) in the subquery, but that's just ignoring the problem.

To ferret out the offending row(s), issue:

	select b.fn, count(*)
	from divername a, pers_info b
	where a.last_name = b.lastn
	and a.first_name = b.firstn
	group by b.fn
	having count(*) > 1

>
>The only difference I had before was there was only one pair of fields that
>need to be equal, here I need two pairs as stated above.
>
>Any help or pointers would be much appreciated.
>
>
>Selina Glynn
Received on Thu Jun 16 1994 - 01:48:07 CEST

Original text of this message