473,397 Members | 1,969 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,397 software developers and data experts.

correlated update headache (db2 unix)

2
(aix 5.1, db2 8.1.6)

Consider this toy example:
--------------------
create table foo ( alpha int, beta int );

insert into foo ( 100, -1 );
insert into foo ( 200, -1 );
insert into foo ( 300, -1 );

update foo x set beta = ( select count(*) from foo y where y.beta >= 0 );
--------------------

I would swear I ran code like this ages ago,
and it generated smth like these results:
: alpha beta :
: 100 0 :
: 200 1 :
: 300 2 :

I expected something like this because the update
will evaluate each row in foo.
The first time it evaluates the nested-select,
all values of beta are negative, so the count(*) will
yield 0.

The 2nd time it evaluates the nested-select,
most values of beta are negative (one is zero),
so the count(*) should yield 1.

etc.


What I'm getting is:
: alpha beta :
: 100 0 :
: 200 0 :
: 300 0 :

Now I really do not care about the order of alpha: any permutation
would be fine, e.g.
: alpha beta : alpha beta : alpha beta :
: 100 2 : 100 1 : 100 2 :
: 200 1 : 200 0 : 200 0 :
: 300 0 : 300 2 : 300 1 :


Is there a query option or smth I can set to make db2/udb's
update work like this?
Thanks, John G.
Nov 16 '06 #1
1 1822
jgreve
2
Sorry, never mind. My memory was probably playing tricks on me. If I knew how to delete a thread, I'd kill this one.

Trying to read from a modified table in-flight is probably goes against some principle in sql's data model.

(Though if you do know of a way to do this, please tell me :-)
Nov 16 '06 #2

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

Similar topics

100
by: Peter | last post by:
Company thought DB2 will be better than Oracle. The bottom line is when you do select, the system crash. I think it may take 4-5 years for DB2 to reach Oracle standard. Peter
0
by: Murali | last post by:
Hi All I was reading thro the posting(s) of Thomas Kyte and his nifty approach to doing updates without the need for unnecessary correlated subqueries. An alternative to correlated subquery...
7
by: CT | last post by:
Hi, This might seem like a basic question but I have some doubts, please humour me. I have a client-server application using java where each client on each machine needs to directly...
1
by: Mike L. Bell | last post by:
Query: update table1 t1 set end_time = ( select end_time from table2 t2 where t2.key1 = t1.key1 and t2.key2 = t1.key2 ) where exists
375
by: rkusenet | last post by:
This article is very bleak about future of DB2. How credible is the author. http://www.eweek.com/article2/0,1895,1839681,00.asp
8
by: Venkata C | last post by:
Hi! Does anyone here know of a way to goad DB2 into converting a correlated subquery to a non-correlated one? Does DB2 ever do such a conversion? We have a query of the form SELECT .. FROM A...
3
by: spartacus | last post by:
Hi, Does SQL support update to multiple rows where values coming from a sub-query? e.g insert into TABLE1 select column1, column2, column3 from TABLE2
3
by: taru | last post by:
Env: DB2 UDB 8.1 on AIX We are executing a db2 sql stored procedure which is invoked from a java client. The stored procedure contains few select, insert and update statements. Using the DB2...
2
by: benfly08 | last post by:
Hi, Folks. I got a scenario that cause me headache. Currently our company is using an AS/400 Server which run DB2 to hold all critical data(I called it remote site). I dont' have acess...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.