Re: Please Help with SQL Statement

From: Chuck Hamilton <chuckh_at_ix.netcom.com>
Date: 1995/06/28
Message-ID: <3srmt6$p1m_at_ixnews6.ix.netcom.com>#1/1


In <id.I24L1.S06_at_nmti.com> neuwirth_at_nmti.com (Howard Neuwirth-Hirsch) writes:
>
>I have two input tables:
>
>LINEAR
>
>ENTRY_NO FACTOR CONST
>-------- ------ -----
> 1 .875 1
> 2 1.000 0
> 3 .436 20
> 4 .222 0
> 5 .943 -15
>
>
>RAWDATA
>
>UID CHAR_NO
>--- -------
>CST 3
>MUS 5
>PUP 2
> .
> .
>
>
>FINALDAT
>
>NAME SCALE BIAS
>---- ----- ----
>CST
>MUS
>PUP
>
>There is a one-to-one correspondence between the records in RAWDATA
>and FINALDAT, i.e. FINALDAT was built from RAWDATA. I now want to
>populate the bias column from RAWDATA and LINEAR. I have tried the
>following:
>
>update FINALDAT set bias= (select CONST from LINEAR,RAWDATA,FINALDAT
>where (FINALDAT.NAME = RAWDATA.UID and LINEAR.ENTRY_NO =
 RAWDATA.CHAR_NO));
>
>the result of this is:
>
>update FINALDAT set bias= (select CONST from LINEAR,RAWDATA,FINALDAT
> *
>ERROR at line 1:
>ORA-01427: single-row subquery returns more than one row
>
>Any suggestions?

Don't put the finaldat table into the sub-query. The following should do what you want...

UPDATE finaldat SET bias =

	(SELECT const FROM rawdata,linear
	WHERE rawdata.char_no = linear.entry_no
	AND finaldat.name = rawdata.id);


-- 
Chuck Hamilton
chuckh_at_ix.netcom.com

Never share a foxhole with anyone braver than yourself!
Received on Wed Jun 28 1995 - 00:00:00 CEST

Original text of this message