DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: multiple updates problem

  1. #1
    Join Date
    Nov 1999
    Posts
    226
    HI

    The SQL I am using is

    update rafiq set RECIPIENTNAME = (select RECIPIENTNAME from rffragrecipient where
    rafiq.shrfnbr=rffragrecipient.shrfnbr )

    I am getting an error - subquery retieves more than 1 row .


    Please tell em how should I write it

    regards

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You can write it like:
    update rafiq set RECIPIENTNAME = (select min(RECIPIENTNAME) from rffragrecipient where
    rafiq.shrfnbr=rffragrecipient.shrfnbr )

    However, the reason you are getting this message is because Oracle can't find one and only one match for rafiq.shrfnbr in rffragrecipient by shrfnbr. Typically, this condition arises from either a design flaw or a misunderstanding of the data.
    Jeff Hunter

  3. #3
    Join Date
    Jun 2000
    Location
    Conway,AR,USA
    Posts
    29
    Step 1.
    Check if the query
    select RECIPIENTNAME
    from rffragrecipient,rafiq
    where rafiq.shrfnbr=rffragrecipient.shrfnbr
    returns more than 1 row.
    If yes
    then
    Step 2.
    Change the query
    select RECIPIENTNAME
    from rffragrecipient,rafiq
    where rafiq.shrfnbr=rffragrecipient.shrfnbr
    to suit your business requirement min(RECIPIENTNAME) or
    max(RECIPIENTNAME) or distinct(RECIPIENTNAME) or the first value returned or the last value returned.

    Soumya
    still learning

  4. #4
    Join Date
    Nov 1999
    Posts
    226
    Thanks !!

    There were actually repeated rows in teh table taht I did not know .

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width