Tuesday 5 September 2017

SQL Query - How to Remove Account from User's Account Tab in OIM.

Below SQL queries will remove specified account from user account tab.


1. Delete entry from child table:


Note: Execute this query if application has entitlements.

DELETE FROM <Replace_Child_Table_Name>
WHERE ORC_KEY IN
  (SELECT OIU.ORC_KEY FROM OIU, <Replace_Child_Table_Name> CT
     WHERE OIU.ORC_KEY = CT.ORC_KEY
     AND OIU.APP_INSTANCE_KEY = (SELECT APP_INSTANCE_KEY FROM  APP_INSTANCE WHERE APP_INSTANCE_NAME = '<Replace_Application_Instance_Name>')
  );

2. Delete entry from parent table:


DELETE FROM <Replace_Parent_Table_Name>
WHERE ORC_KEY IN
  (SELECT OIU.ORC_KEY FROM OIU, <Replace_Parent_Table_Name> PT
WHERE OIU.ORC_KEY= PT.ORC_KEY
AND OIU.APP_INSTANCE_KEY = (SELECT APP_INSTANCE_KEY FROM APP_INSTANCE WHERE APP_INSTANCE_NAME = '<Replace_Application_Instance_Name>')
  );


3. Delete entry from OIU table:


DELETE FROM OIU
WHERE ORC_KEY IN
  (SELECT OIU.ORC_KEY FROM OIU, ORC
WHERE OIU.ORC_KEY = ORC.ORC_KEY
AND OBI_KEY IN (SELECT OBI_KEY FROM OBI WHERE OBJ_KEY = (SELECT OBJ_KEY FROM OBJ WHERE OBJ_NAME = '<Replace_Resource_Object_Name>'))
);



Happy Learning!!!

2 comments:

  1. Can you please tell me in above query where are we giving user id or user key to delete account for a particular user.

    ReplyDelete
  2. These queries will remove all the data. Please refine these queries specific to user.

    ReplyDelete