SQL view and Tracked Entity Relationship

Is there a way to resolve the issue with the SQL view in DHIS2 when trying to extract enrollment profiles for tracked entities and their related enrollment profiles? I have a tracked entity that holds information about mothers, and it is connected to another entity that contains information about their children. However, when attempting to retrieve this information using SQL views, I encountered an error stating that the SQL query references protected tables. Since DHIS2 does not have a built-in feature to display related entities, I would like to know if there is a solution to this problem. DHIS2 v2.39, OS Ubuntu 20, tomcat9, PG 14.

@dhis2-analytics @dhis2-backend @dhis2-tracker @Gassim @jason

Hi @JohnasSolomon
One way is by disabling the restrictions on the protected tables in the dhis.conf configuration file.

system.sql_view_table_protection = on | off

This obviously comes with security risks, but it is one way.

The other way, which I would recommend would be the approach outlined by @Calle_Hedberg here. At least with this route, you do not open potential access to all of the protected tables.

Regards,
Jason

1 Like

Thank you @jason. I appreciate your suggestions and would like to request further clarification on the second solution you mentioned. I didn’t fully grasp its details.