dbMakeConsistent_db2.sql 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. -- Licensed Materials - Property of IBM
  2. --
  3. -- BI and PM: CM
  4. --
  5. -- (C) Copyright IBM Corp. 2008, 2019
  6. --
  7. -- US Government Users Restricted Rights - Use, duplication or disclosure
  8. -- restricted by GSA ADP Schedule Contract with IBM Corp.
  9. -- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. -- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. insert into CMOBJNAMES (CMID, LOCALEID, MAPDLOCALEID, ISDEFAULT, NAME) select CMID, 24, 24, 1, CONCAT( 'REPAIRED BY CONSISTENCY CHECK ', VARCHAR( TIMESTAMP( GENERATE_UNIQUE() ))) from CMOBJECTS where CMID not in (select CMID from CMOBJNAMES);
  12. insert into CMPOLICIES (CMID) select CMID from CMOBJECTS where CMID not in (select CMID from CMPOLICIES);
  13. insert into CMSTOREIDS (CMID, STOREID) select CMID, SUBSTR('i00000000000000000000000000000000',1,33 - LENGTH(RTRIM(CAST(CMID AS CHAR(10))))) || RTRIM(CAST(CMID AS CHAR(10))) from CMOBJECTS where CMID not in (select CMID from CMSTOREIDS);
  14. update CMSTOREIDS set STOREID = NULL where UPPER(STOREID) in (select UPPERSTOREIDS.STOREID from (select b.CMID, UPPER(b.STOREID) as STOREID from CMSTOREIDS b) as UPPERSTOREIDS group by UPPERSTOREIDS.STOREID having COUNT(UPPERSTOREIDS.CMID) > 1);
  15. update CMSTOREIDS set STOREID = SUBSTR('i00000000000000000000000000000000',1,33 - LENGTH(RTRIM(CAST(CMID AS CHAR(10))))) || RTRIM(CAST(CMID AS CHAR(10))) where CMID in (select CMID from CMSTOREIDS where STOREID is null);
  16. delete from CMOBJNAMES where CMID not in (select CMID from CMOBJECTS);
  17. delete from CMDATA where CMID not in (select CMID from CMOBJECTS);
  18. delete from CMOBJPROPS1 where CMID not in (select CMID from CMOBJECTS);
  19. delete from CMOBJPROPS10 where CMID not in (select CMID from CMOBJECTS);
  20. delete from CMOBJPROPS11 where CMID not in (select CMID from CMOBJECTS);
  21. delete from CMOBJPROPS13 where CMID not in (select CMID from CMOBJECTS);
  22. delete from CMOBJPROPS14 where CMID not in (select CMID from CMOBJECTS);
  23. delete from CMOBJPROPS15 where CMID not in (select CMID from CMOBJECTS);
  24. delete from CMOBJPROPS16 where CMID not in (select CMID from CMOBJECTS);
  25. delete from CMOBJPROPS17 where CMID not in (select CMID from CMOBJECTS);
  26. delete from CMOBJPROPS18 where CMID not in (select CMID from CMOBJECTS);
  27. delete from CMOBJPROPS2 where CMID not in (select CMID from CMOBJECTS);
  28. delete from CMOBJPROPS20 where CMID not in (select CMID from CMOBJECTS);
  29. delete from CMOBJPROPS23 where CMID not in (select CMID from CMOBJECTS);
  30. delete from CMOBJPROPS24 where CMID not in (select CMID from CMOBJECTS);
  31. delete from CMOBJPROPS25 where CMID not in (select CMID from CMOBJECTS);
  32. delete from CMOBJPROPS26 where CMID not in (select CMID from CMOBJECTS);
  33. delete from CMOBJPROPS27 where CMID not in (select CMID from CMOBJECTS);
  34. delete from CMOBJPROPS28 where CMID not in (select CMID from CMOBJECTS);
  35. delete from CMOBJPROPS30 where CMID not in (select CMID from CMOBJECTS);
  36. delete from CMOBJPROPS31 where CMID not in (select CMID from CMOBJECTS);
  37. delete from CMOBJPROPS32 where CMID not in (select CMID from CMOBJECTS);
  38. delete from CMOBJPROPS33 where CMID not in (select CMID from CMOBJECTS);
  39. delete from CMOBJPROPS34 where CMID not in (select CMID from CMOBJECTS);
  40. delete from CMOBJPROPS35 where CMID not in (select CMID from CMOBJECTS);
  41. delete from CMOBJPROPS36 where CMID not in (select CMID from CMOBJECTS);
  42. delete from CMOBJPROPS37 where CMID not in (select CMID from CMOBJECTS);
  43. delete from CMOBJPROPS38 where CMID not in (select CMID from CMOBJECTS);
  44. delete from CMOBJPROPS39 where CMID not in (select CMID from CMOBJECTS);
  45. delete from CMOBJPROPS3 where CMID not in (select CMID from CMOBJECTS);
  46. delete from CMOBJPROPS4 where CMID not in (select CMID from CMOBJECTS);
  47. delete from CMOBJPROPS40 where CMID not in (select CMID from CMOBJECTS);
  48. delete from CMOBJPROPS41 where CMID not in (select CMID from CMOBJECTS);
  49. delete from CMOBJPROPS42 where CMID not in (select CMID from CMOBJECTS);
  50. delete from CMOBJPROPS43 where CMID not in (select CMID from CMOBJECTS);
  51. delete from CMOBJPROPS44 where CMID not in (select CMID from CMOBJECTS);
  52. delete from CMOBJPROPS45 where CMID not in (select CMID from CMOBJECTS);
  53. delete from CMOBJPROPS46 where CMID not in (select CMID from CMOBJECTS);
  54. delete from CMOBJPROPS47 where CMID not in (select CMID from CMOBJECTS);
  55. delete from CMOBJPROPS48 where CMID not in (select CMID from CMOBJECTS);
  56. delete from CMOBJPROPS49 where CMID not in (select CMID from CMOBJECTS);
  57. delete from CMOBJPROPS5 where CMID not in (select CMID from CMOBJECTS);
  58. delete from CMOBJPROPS50 where CMID not in (select CMID from CMOBJECTS);
  59. delete from CMOBJPROPS51 where CMID not in (select CMID from CMOBJECTS);
  60. delete from CMOBJPROPS52 where CMID not in (select CMID from CMOBJECTS);
  61. delete from CMOBJPROPS53 where CMID not in (select CMID from CMOBJECTS);
  62. delete from CMOBJPROPS54 where CMID not in (select CMID from CMOBJECTS);
  63. delete from CMOBJPROPS55 where CMID not in (select CMID from CMOBJECTS);
  64. delete from CMOBJPROPS56 where CMID not in (select CMID from CMOBJECTS);
  65. delete from CMOBJPROPS57 where CMID not in (select CMID from CMOBJECTS);
  66. delete from CMOBJPROPS58 where CMID not in (select CMID from CMOBJECTS);
  67. delete from CMOBJPROPS59 where CMID not in (select CMID from CMOBJECTS);
  68. delete from CMOBJPROPS6 where CMID not in (select CMID from CMOBJECTS);
  69. delete from CMOBJPROPS60 where CMID not in (select CMID from CMOBJECTS);
  70. delete from CMOBJPROPS61 where CMID not in (select CMID from CMOBJECTS);
  71. delete from CMOBJPROPS62 where CMID not in (select CMID from CMOBJECTS);
  72. delete from CMOBJPROPS63 where CMID not in (select CMID from CMOBJECTS);
  73. delete from CMOBJPROPS64 where CMID not in (select CMID from CMOBJECTS);
  74. delete from CMOBJPROPS65 where CMID not in (select CMID from CMOBJECTS);
  75. delete from CMOBJPROPS66 where CMID not in (select CMID from CMOBJECTS);
  76. delete from CMOBJPROPS67 where CMID not in (select CMID from CMOBJECTS);
  77. delete from CMOBJPROPS68 where CMID not in (select CMID from CMOBJECTS);
  78. delete from CMOBJPROPS69 where CMID not in (select CMID from CMOBJECTS);
  79. delete from CMOBJPROPS7 where CMID not in (select CMID from CMOBJECTS);
  80. delete from CMOBJPROPS70 where CMID not in (select CMID from CMOBJECTS);
  81. delete from CMOBJPROPS71 where CMID not in (select CMID from CMOBJECTS);
  82. delete from CMOBJPROPS72 where CMID not in (select CMID from CMOBJECTS);
  83. delete from CMOBJPROPS73 where CMID not in (select CMID from CMOBJECTS);
  84. delete from CMOBJPROPS74 where CMID not in (select CMID from CMOBJECTS);
  85. delete from CMOBJPROPS75 where CMID not in (select CMID from CMOBJECTS);
  86. delete from CMOBJPROPS76 where CMID not in (select CMID from CMOBJECTS);
  87. delete from CMOBJPROPS77 where CMID not in (select CMID from CMOBJECTS);
  88. delete from CMOBJPROPS78 where CMID not in (select CMID from CMOBJECTS);
  89. delete from CMOBJPROPS79 where CMID not in (select CMID from CMOBJECTS);
  90. delete from CMOBJPROPS80 where CMID not in (select CMID from CMOBJECTS);
  91. delete from CMOBJPROPS81 where CMID not in (select CMID from CMOBJECTS);
  92. delete from CMOBJPROPS82 where CMID not in (select CMID from CMOBJECTS);
  93. delete from CMOBJPROPS83 where CMID not in (select CMID from CMOBJECTS);
  94. delete from CMOBJPROPS84 where CMID not in (select CMID from CMOBJECTS);
  95. delete from CMOBJPROPS85 where CMID not in (select CMID from CMOBJECTS);
  96. delete from CMOBJPROPS86 where CMID not in (select CMID from CMOBJECTS);
  97. delete from CMOBJPROPS87 where CMID not in (select CMID from CMOBJECTS);
  98. delete from CMOBJPROPS88 where CMID not in (select CMID from CMOBJECTS);
  99. delete from CMOBJPROPS89 where CMID not in (select CMID from CMOBJECTS);
  100. delete from CMOBJPROPS9 where CMID not in (select CMID from CMOBJECTS);
  101. delete from CMOBJPROPS90 where CMID not in (select CMID from CMOBJECTS);
  102. delete from CMOBJPROPS91 where CMID not in (select CMID from CMOBJECTS);
  103. delete from CMOBJPROPS92 where CMID not in (select CMID from CMOBJECTS);
  104. delete from CMOBJPROPS93 where CMID not in (select CMID from CMOBJECTS);
  105. delete from CMPOLICIES where CMID not in (select CMID from CMOBJECTS);
  106. delete from CMVIEWED where CMID not in (select CMID from CMOBJECTS);
  107. delete from CMGUIDS where CMID not in (select CMID from CMOBJECTS);
  108. delete from CMREFNOORD1 where CMID not in (select CMID from CMOBJECTS);
  109. delete from CMREFNOORD2 where CMID not in (select CMID from CMOBJECTS);
  110. delete from CMREFORD1 where CMID not in (select CMID from CMOBJECTS);
  111. delete from CMREFORD2 where CMID not in (select CMID from CMOBJECTS);
  112. delete from CMSTOREIDS where CMID not in (select CMID from CMOBJECTS);
  113. delete from CMARCHIVESTATUS where CMID not in (select CMID from CMOBJECTS);
  114. delete from CMTAGS where CMID not in (select CMID from CMOBJECTS);