Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update, Set, and Select

Posted on 2003-10-24
4
Medium Priority
?
8,378 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 60 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

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 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