home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Neueste VersionenFixList
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
Haben Sie Probleme? - Kontaktieren Sie uns.
Kostenlos registrieren anmeldung-x26
Kontaktformular kontakt-x26

DB2 - Problembeschreibung

Problem IC63909 Status: Geschlossen

MERGE STATEMENT INSERTING INCORRECT DEFAULT VALUE INTO A VIEW WITH
INSTEAD OF TRIGGER

Produkt:
DB2 FOR LUW / DB2FORLUW / 970 - DB2
Problembeschreibung:
MERGE statement may insert incorrect default value into a view 
when all of the following conditions are satisfied: 
 
1. The target of the MERGE statement is a view. 
 
2. An INSTEAD OF INSERT TRIGGER is defined on the view. 
 
3. The MERGE statement has an INSERT operation that specifies 
only a subset of the columns of the view and those missing 
columns are to be substituted with the default value of the 
columns. 
 
4. The WHEN clause containing the INSERT operation is specified 
after a WHEN clause containing an UPDATE or DELETE operation in 
the MERGE statement. 
 
 
Sample scenario : 
 
  $ db2 "create table T1 ( C1 char(1) with default '0', C2 
char(1) with default '0' )" 
  $ db2 "create table T2 ( C1 char(1) with default '0', C2 
char(1) with default '0' )" 
  $ db2 "create view V1 ( T1C1, T2C2 ) as select T1.C1, T2.C2 
from T1, T2 where T1.C1=T2.C1" 
  $ db2 "create trigger TRI instead of insert on V1 
        referencing new as NEW for each row 
        begin atomic 
            insert into T1 ( C1, C2 ) values ( NEW.T1C1, 
NEW.T2C2 ); 
            insert into T2 ( C1, C2 ) values ( NEW.T1C1, 
NEW.T2C2 ); 
        end" 
  $ db2 "create trigger TRU instead of update on V1 
        referencing new as NEW for each row 
            begin atomic 
            end" 
  $ db2 "create trigger TRD instead of delete on V1 
        referencing old as OLD for each row 
            begin atomic 
            end" 
  $ db2 "merge into V1 using table ( values ( '9' ) ) as DMY ( 
T1C1 ) on ( V1.T1C1 = DMY.T1C1 ) 
        when matched     then update set T1C1 = '4' 
        when not matched then insert ( T1C1 ) values ( '3' )" 
 
  > DB20000I  The SQL command completed successfully. 
 
  $ db2 "select * from V1" 
 
  > T1C1 T2C2 
    ---- ---- 
    3 
 
      1 record(s) selected. 
 
  ==> Its result should be "3    -"
Problem-Zusammenfassung:
**************************************************************** 
* USERS AFFECTED:                                              * 
* All                                                          * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See APAR Description text                                    * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to DB2 Version 9.7 Fix Pack 1.                       * 
****************************************************************
Local-Fix:
Avoid using default values in the INSERT operations of the MERGE 
statement. 
 
  $ db2 "merge into V1 using table ( values ( '9' ) ) as DMY ( 
T1C1 ) on ( V1.T1C1 = DMY.T1C1 ) 
        when matched     then update set T1C1 = '4' 
        when not matched then insert ( T1C1, T2C2 ) values ( 
'5', NULL )" 
 
  > DB20000I  The SQL command completed successfully. 
 
  $ db2 "select * from V1" 
 
  > T1C1 T2C2 
    ---- ---- 
    3 
    5    - 
 
      2 record(s) selected.
verfügbare FixPacks:
DB2 Version 9.7 Fix Pack 1 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 2 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 3a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 4 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 5 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 7 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9a for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 6 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 8 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 9 for Linux, UNIX, and Windows
DB2 Version 9.7 Fix Pack 10 for Linux, UNIX, and Windows

Lösung
Problem was first fixed in DB2 Version 9.7 Fix Pack 1.
Workaround
keiner bekannt / siehe Local-Fix
Weitere Daten
Datum - Problem gemeldet    :
Datum - Problem geschlossen :
Datum - der letzten Änderung:
21.10.2009
16.02.2010
16.02.2010
Problem behoben ab folgender Versionen (IBM BugInfos)
9.7.FP1
Problem behoben lt. FixList in der Version
9.7.0.1 FixList