Solved

Update, Set, and Select

Posted on 2003-10-24
4
8,369 Views
Last Modified: 2013-12-01
Can anyone tell me why this statement is not working.  I keep getting a

ORA-01427: single-row subquery returns more than one row  

error

UPDATE tmp10110191
   SET mnth_sales_amt =
          (SELECT   SUM (dlycsh.sales_amt)
               FROM tmx.dlycsh, chgdata.tmp10110191
              WHERE dlycsh.tran_dt >= TO_DATE ('01/01/03', 'MM/DD/YY')
                AND dlycsh.tran_dt <= TO_DATE ('10/22/03', 'MM/DD/YY')
           GROUP BY dlycsh.site_no)

Thanks,

jms
0
Comment
Question by:jmsloan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 22

Expert Comment

by:Helena Marková
ID: 9625117
I think that there are more dlycsh.site_no (GROUP BY dlycsh.site_no) than one there.
0
 
LVL 2

Expert Comment

by:renuraj
ID: 9635131
Could you post us the table tmp10110191 structure!

If tmp10110191 table has site_no column, SQL below will do
UPDATE tmp10110191 t
   SET t.mnth_sales_amt =
          (SELECT   SUM (dlycsh.sales_amt)
               FROM tmx.dlycsh, chgdata.tmp10110191
              WHERE dlycsh.tran_dt >= TO_DATE ('01/01/03', 'MM/DD/YY')
                AND dlycsh.tran_dt <= TO_DATE ('10/22/03', 'MM/DD/YY')
                AND dlycsh.site_no = t.site_no)

Regards,
0
 
LVL 3

Accepted Solution

by:
evedder earned 20 total points
ID: 9654255

Your subquery is returning multiple rows, maybe you should test first the subquery alone and see how many rows it retrieves you, if you receive more than one row you have to use an "any" or "all" clause for comparisons

like

UPDATE tmp10110191
   SET mnth_sales_amt > any
          (SELECT   SUM (dlycsh.sales_amt)
               FROM tmx.dlycsh, chgdata.tmp10110191
              WHERE dlycsh.tran_dt >= TO_DATE ('01/01/03', 'MM/DD/YY')
                AND dlycsh.tran_dt <= TO_DATE ('10/22/03', 'MM/DD/YY')
           GROUP BY dlycsh.site_no)


that is talking about syntax but to make your statement to work properly we need to know the logistic

regards!
0
 

Expert Comment

by:ksrsrao
ID: 10587210
hi
u must use where condition after subqry
ex given  below
update bak_party_fa a set add1=(select substr(add1,1,30) from bak_party
where a.party_code=acct_head) where party_code in
(select b.acct_head from bak_party b)
regards
kalaga
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
Verbose logging is used to diagnose garbage collector problems. By default, -verbose:gc output is written to either native_stderr.log or native_stdout.log.   It is also possible to redirect the logs to a user-specified file. This article will de…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question