single row subquery returns more then one row
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: single row subquery returns more then one row

  1. #1
    Join Date
    Mar 2005
    Posts
    143

    single row subquery returns more then one row

    I am trying to update the txstatus field of the trx table with the value of the pgroup field in the producer table in our oracle db. both tables have a field called producer and that is where I am linking them. so for example if the trx table has the following
    producer Txstatus
    S1234
    S1235
    S1236
    and the producer table has
    pgroup producer
    GRAD S1234
    GRAD S1235
    PERIO S1236

    I want the trx table to now look like this
    txstatus Producer
    GRAD S1234
    GRAD S1235
    PERIO S1236

    I am running this:
    update trx set "TxStatus"= ( select a."PGroup" from Producer A, TRX b where a."Producer" = b."Producer") and getting the error:
    single row subquery returns more then one row
    I understand why I get the error, I am just not sure how to correct my code. Could anyone help?

  2. #2
    Join Date
    May 2002
    Posts
    2,645
    Make this part return no more than one row:

    select a."PGroup" from Producer A, TRX b where a."Producer" = b."Producer"

  3. #3
    Join Date
    Mar 2005
    Posts
    143
    this worked:
    update trx a set a."TxStatus" = (select b."PGroup" from Producer B where a."Producer"=b."Producer" )
    Last edited by jayjabour; 01-05-2011 at 01:09 PM.

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