37 lines
2.5 KiB
Markdown
37 lines
2.5 KiB
Markdown
# SQL-commands-request-for-Issue-2126361---Reconciliation-Issue-due-to-duplication-of-PK-in-URM-History_686074742
|
||
For the case
|
||
|
||
[Issue 2126361 - Reconciliation Issue due to duplication of PK in URM History](https://internal.almoctane.com/ui/entity-navigation?p=97002/20001&entityType=work_item&id=2126361), Customer was blocked by a DB duplicated error when trying to update CI type model in CMS.
|
||
|
||
***Case ID:*** OCTIM19U2126361 Reconciliation Issue due to duplication of PK in URM History
|
||
|
||
***Justification of the change*:** Delete the duplicated record from URM\_RESOURCES\_HISTORY table.
|
||
|
||
***Risk Impact Analysis:*** No
|
||
|
||
***SQL statement:***
|
||
|
||
**Get all duplicated history records in urm\_resources\_history table.**
|
||
|
||
SELECT h.\* from urm\_resources u,urm\_resources\_history h where h.CUSTOMER\_ID='502897868' and u.real\_id=h.real\_id and u.commit\_revision=h.commit\_revision and u.type NOT IN ('UI\_RECENTLY\_OPENED\_RESOURCES','UI\_INVENTORY\_SETTINGS','History\_HIST\_FAILURE','UI\_DASHBOARD\_SETTINGS','UI\_USER\_PREFERENCES','UI\_CARD\_LAYOUT\_SETTINGS','UI\_PROTOCOL\_DECORATION','Settings\_PROPERTY\_SETTING');
|
||
|
||
**Backup the duplicated records (depend on query result above)**
|
||
|
||
CREATE TABLE URM\_RESOURCES\_HISTORY\_backup as SELECT h.\* FROM urm\_resources\_history h INNER JOIN urm\_resources u ON u.real\_id = h.real\_id AND u.commit\_revision = h.commit\_revision where h.CUSTOMER\_ID ='502897868' and h.type NOT IN ('UI\_RECENTLY\_OPENED\_RESOURCES','UI\_INVENTORY\_SETTINGS','History\_HIST\_FAILURE','UI\_DASHBOARD\_SETTINGS','UI\_USER\_PREFERENCES','UI\_CARD\_LAYOUT\_SETTINGS','UI\_PROTOCOL\_DECORATION','Settings\_PROPERTY\_SETTING');
|
||
|
||
**Remove duplicated records in URM Resources History table.**
|
||
|
||
DELETE from urm\_resources\_history h where exists (select 1 from urm\_resources r where r.real\_id = h.real\_id and r.commit\_revision = h.commit\_revision and h.customer\_id = '502897868' and h.type NOT IN ('UI\_RECENTLY\_OPENED\_RESOURCES','UI\_INVENTORY\_SETTINGS','History\_HIST\_FAILURE','UI\_DASHBOARD\_SETTINGS','UI\_USER\_PREFERENCES','UI\_CARD\_LAYOUT\_SETTINGS','UI\_PROTOCOL\_DECORATION','Settings\_PROPERTY\_SETTING'));
|
||
|
||
***Rollback SQL statement:***
|
||
|
||
**Restore the backup records from URM\_RESOURCES\_HISTORY\_backup into urm\_resources\_history table:**
|
||
|
||
INSERT into urm\_resources\_history select \* from URM\_RESOURCES\_HISTORY\_backup;
|
||
|
||
Drop Table URM\_RESOURCES\_HISTORY\_backup;
|
||
|
||
***SA Review/Sign-off:*** [*@Jun-Wu 'Thomas' Pan*](mailto:jun-wu.pan@microfocus.com) [@Fei Wu](mailto:wu.fei@microfocus.com)
|
||
|
||
***CPE owner name* *:*** *Shi Nuo*
|