fiogf49gjkf0d Also, you may need a better understanding of how AdhocGroups works specially when it comes to Releases and Copies.
There are 3 fields on the Plugin Table that are of Importance when Dealing with Groups:
PLUGINID, BASEDON and DATACODE. *The DataCode column is the ID that is used to query data from the AdhocGroup Table.
If you create an Adhoc Group, the PluginID will be the GroupID, the BasedOn will be Null and the DataCode will the GroupID.
If you Release this group a new Record (or multiple Records) will be created. Each Release Record will have its own GroupID. The BasedOn and DataCode fields will have the GroupID of the Original Group.
If you make a Copy of this group, the BasedOn should be Blank (as it is not a Release), but the DataCode remains pointing to the Original Group (this is based on my observation, and may be a bug).
What this means is that based on the SQL Statements that you had created, you may end up leaving a Bunch of Release Copies of the AdHoc Groups still available (although with no records to be displayed).
So, the best approach may be as follows:
a) Delete the Plugin records
DELETE FROM PLUGIN WHERE TYPE = 8 AND FAMILY IN ('Account', 'Contact')
(DATACODE IN (SELECT GROUPID FROM ADHOCGROUP) OR PLUGINID IN (SELECT GROUPID FROM ADHOCGROUP))
You may want to consider using this Statement instead:
DELETE FROM PLUGIN WHERE TYPE = 8 AND FAMILY IN ('Account', 'Contact') AND DATACODE <> ''
b) Delete the Records from the AdhocGroup Table
I would suggest you just do a cleanup of this table. Since you deleted the Plugin Records, just go for:
DELETE FROM ADHOCGROUP WHERE GROUPID NOT IN (SELECT PLUGINID FROM PLUGIN)
Finally, there are many reasons why your numbers don't match, but the most likely one is Orphaned Data.
It is quite Common to find Records on the AdhocGroup table where the GroupID doesn't match any Existing plugins records. |