home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IC80975 Status: Closed

SELECT FROM AN UPDATE/DELETE/INSERT IN COMMON TABLE EXPRESSION GIVES WRONG
RESULTS.

product:
DB2 FOR LUW / DB2FORLUW / 950 - DB2
Problem description:
Under rare cases, a query satisfying the following conditions 
might produce wrong results: 
1. The query has a common table expression (CTE). 
2. The CTE has a select over an update/delete/insert (UDI) 
3. The select in the CTE has a fetch first n rows. 
4. The value to be set also comes from the same table on which 
UDI is taking place 
 
eg. 
WITH updated AS (   CTE 
select * 
<outer select 
from final table( 
        update db2admin.SE_CUSTOMER_PRODUCT_TEMP_test c 
< UDI 
        set PROCESS_FLAG=(select 11 from 
DB2admin.SE_CUSTOMER_PRODUCT_TEMP_test <select on same table 
                                        fetch first row only) 
where PROCESS_FLAG=0  )s 
fetch first 10 rows only)                    <its downlaoding 
fetch first n rows on outer select 
select * from updated; 
 
This query should update all records in the table but only 
output 10 records. Actual result is updation of 10-12 rows only. 
 
Rewritten version: 
WITH updated AS ( 
select * 
from final table( 
        update db2admin.SE_CUSTOMER_PRODUCT_TEMP_test c 
        set PROCESS_FLAG=(select 11 from 
DB2admin.SE_CUSTOMER_PRODUCT_TEMP_test 
                                        fetch first row only) 
where PROCESS_FLAG=0  )s 
) 
( fetch first n rows on outer select removed 
select * from updated fetch first 10 rows only; 
( fetch first n rows placed in query)
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* All                                                          * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to DB2 version 950 fixpack 10                        * 
****************************************************************
Local Fix:
fetch first n rows should be removed from the CTE and put in the 
actual query
Solution
The problem was first fixed in DB2 version 950 fixpack 10
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
23.01.2012
30.10.2012
30.10.2012
Problem solved at the following versions (IBM BugInfos)
9.5.0
Problem solved according to the fixlist(s) of the following version(s)
9.5.0.10 FixList