473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Having problems to build a proper update in oracle10g

Hi!

I'm having problems with my update below. I know there's a where -clause missing, but I just can't figure out how it should be done properly. I'm stuck with that ORA-01427.

Thanks for advice! OV.

UPDATE apuarea pa SET pa.subarea =
(SELECT pu.subarea FROM prounit pu, popperson pp, popresidence pr
WHERE substr(pr.buildinglabel,1, 14) = pu.unitlabel
AND pr.enddate IS NULL
AND pp.id = pr.poppersonid
AND pp.id = pa.poppersonid
AND pu.regstatus = 1
AND pp.registerstate = 1
AND pa.municipality = '179'
AND pa.islivingpermanent = 1
AND pa.enddate IS NULL
AND pr.poppersonid = pa.poppersonid
AND pu.unittype = 1
AND pu.regunitclass IN (1,13)
AND pu.subarea IS NOT NULL);

(SELECT pu.subarea FROM prounit pu, popperson pp, popresidence pr
*
ERROR at line 2:
ORA-01427: single-row subquery returns more than one row
Aug 10 '10 #1
4 1600
Oralloy
988 Expert 512MB
I may be wrong, but I think you want your UPDATE to look more like the following:

Expand|Select|Wrap|Line Numbers
  1. UPDATE apuarea pa
  2.   SET pa.subarea = (SELECT pu.subarea
  3.                       FROM prounit pu, popperson pp, popresidence pr
  4.                       WHERE ((substr(pr.buildinglabel,1, 14) = pu.unitlabel) 
  5.                              AND (pr.enddate IS NULL)
  6.                              AND (pp.id = pr.poppersonid)
  7.                              AND (pp.id = pa.poppersonid)
  8.                              AND (pu.regstatus = 1)
  9.                              AND (pp.registerstate = 1)
  10.                              AND (pr.poppersonid = pa.poppersonid)
  11.                              AND (pu.unittype = 1)
  12.                              AND (pu.regunitclass IN (1,13))
  13.                              AND (pu.subarea IS NOT NULL)))
  14.   WHERE ((pa.municipality = '179')
  15.          AND (pa.islivingpermanent = 1)
  16.          AND (pa.enddate IS NULL))
  17.   ;
Aug 10 '10 #2
rski
700 Expert 512MB
Does this query return more than one row
SELECT pu.subarea FROM prounit pu, popperson pp, popresidence pr
WHERE substr(pr.buildinglabel,1, 14) = pu.unitlabel
AND pr.enddate IS NULL
AND pp.id = pr.poppersonid
AND pp.id = pa.poppersonid
AND pu.regstatus = 1
AND pp.registerstate = 1
AND pa.municipality = '179'
AND pa.islivingpermanent = 1
AND pa.enddate IS NULL
AND pr.poppersonid = pa.poppersonid
AND pu.unittype = 1
AND pu.regunitclass IN (1,13)
AND pu.subarea IS NOT NULL
?
It looks like it does
SELECT pu.subarea FROM prounit pu, popperson pp, popresidence pr
*
ERROR at line 2:
ORA-01427: single-row subquery returns more than one row
It is impossible to set column value to more than one value. The subquery must return only one value (or return null)
Aug 10 '10 #3
Oralloy
988 Expert 512MB
@rski,

Yep. That's what I saw, too.

It looks like he's burried his UPDATE conditions in the sub-select. That will cause all sorts of mischief.

So that's why I suggested the revised update. Or am I missing something?
Aug 10 '10 #4
OraMaster
135 100+
In such case make sure such subqueries should return atmost single value. Otherwise you might have not considered other tables or if you think your select sql is right then you might have bad data in tables or database tables design.
Best Luck
Aug 11 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: paul | last post by:
Hi everyone, I'm having problems displaying a date in the correct format and I was wondering if anyone knew how to help. I'm using pear to extract a date from our back end database (the date is...
0
by: George | last post by:
I have two tables and want to find the Maximum date for a given GIN. I have been able to produce the result in Sybase but I am having problems in Oracle. Example of my query in Sybase. create...
8
by: Michael C | last post by:
Hi all, I'm still having problems with VS.NET 2003 running on my XP machine. I finally decided I might as well uninstall completely and reinstall from scratch. But lo and behold it won't let...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renaeā€™s information. I think that what is going on with...
3
by: TJS | last post by:
looking for generic function to build sql update string for values coming from a form. I've seen these for classic asp but I'm not finding equivalent in asp.net Googleing did not help so far
11
by: Rick Mogstad | last post by:
I know this is probably not the group for this, but i know that these groups are fairly active, and that the people are usually willing to help. Is anyone else experiencing this? The news...
7
by: Ron | last post by:
Hi All, It's taking a long, LONG time for me to see a post from here (and other NGs too, for that matter--which is why I think it may be me...). Sometimes it takes 2-3 minutes after clicking...
2
by: l46kok | last post by:
Hello. This is the first time I'm encountering vectors and I'm having problems. I want to create a vector filled with objects, but as soon as I try to invoke a function within the object, ...
1
by: tshad | last post by:
Some of my regular expressions don't seem to work correctly in IE7. I am on asp.net 1.1. I have a site that has been up for a while and I started having problems on machines with IE7. IE5 and...
3
by: i80and | last post by:
I'm working on a basic web spider, and I'm having problems with the urlparser. This is the effected function: ------------------------------ def FindLinks(Website): WebsiteLen = len(Website)+1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.