I’m trying to delete an indicator group but keep getting the ‘could not execute statement’ message in the UI and a ‘500 (Internal Server Error)’ in the console.
The indicator group no longer has any indicators (these were deleted or moved to another group) and does not belong to an indicator group set.
We are on version 2.33.9.
Any ideas on how to delete this object? Thank you!
I’d suggest to use the Data Administration app → Maintenance → Clear application cache, reload apps, and probably regenerate resource tables and run analytics tables export. Then to avoid any cache issue try in a new profile (or different browser that has not been used to access the instance) to delete the indicator group.
If you still see an issue after all those steps, what do you see if you use this api link: /api/metadata?indicators=false&indicatorGroups=true&fields=*&filter=id:eq:Replace-Indicator-Group-ID-Here? Do you still see any indicators left in that list?
What method are you using to delete the indicator group? Could you try using the Import Export app to export this indicator group and then import it again but choose the delete option, if the app shows you an error, would you please take a screenshot and share?
Hello @Gassim - Thanks for the support
I tried running the maintenance steps that you recommended but still didn’t have any success with deleting the indicator group.
The methods I’ve tried using to delete the group include: (1) the UI; (2) the api with a DELETE call; and (3) using import/export as you recommended. For (1) and (2), I received the same error messages that I mentioned before. For (3), the logger is showing this error ‘Process failed: org.hibernate.exception.ConstraintViolationException: could not execute statement’
When I run the API call you suggested, I can see that the indicator section is empty (as expected).
Are there any dependencies with indicator groups that I need to look in to?
Could you provide the output of the log on the server? The 500 error message points to (very likely) the indicator group not being able to be deleted in the database, probably because of some constraint. However, without the server log its impossible to say what might be causing the problem.
Hi @jason, below is the error in the logs for when I try to delete the indicator group. It looks like it’s being blocked by a dependency with the attribute? However, the attribute value was removed and is no longer visible in the UI/API. In looking into the attribute tables it looks like the attribute values are not getting updated/removed. Is there a way to fix this?
* ERROR 2022-09-22 14:13:51,993 ERROR: update or delete on table "indicatorgroup" violates foreign key constraint "fk49fe5eee8be51834" on table "indicatorgroupattributevalues"
Detail: Key (indicatorgroupid)=(361577) is still referenced from table "indicatorgroupattributevalues". (SqlExceptionHelper.java [http-bio-8080-exec-10])
indicatorgroupattributevalues is a legacy table which is no longer used in 2.33.9 version of DHIS2. It has been replaced with attributevalues column (jsonb) in indicatorgroup table. Any change made to the indicatorgroup attribute value will reflect only in the attributevalues column of indicatorgroup. It is safe to delete the corresponding record in indicatorgroupattributevalues table.
In your case,
delete from indicatorgroupattributevalues where indicatorgroupid = 361577;
should resolve your issue and the indicator group can be deleted from UI (Deleting from UI would run other validations ).
Thank you! I didn’t realize these tables were no longer used.
I was able to delete the indicator group now.