Reset ‘locked’ SQL in Crystal Reports.

Sunday 10 January 2016 @ 5:15 pm

I was helping a customer troubleshoot a misbehaving report. He could add criteria to the report, but when he removed the original criteria from the selection formula the it was still applied. So I looked at the SQL that CR was generating and found that it was not being updated based his our changes.  After a few more tries my customer asked me about an unfamiliar button below the “SHOW SQL QUERY” window. Only then did I noticed the extra button that said RESET.   I had not seen that button in about 10 years, but I now knew the problem with this report.

This report was originally created in an early version of Crystal, probably v8.x. In these early versions you were allowed to tweak the FROM and WHERE clauses in the automatically generated SQL.  This is no longer allowed because now we can create SQL Commands.  Back then, when you modified the SQL it became ‘locked’ and Crystal would no longer update it. If you added more selection criteria the new criteria would not be incorporated into the SQL. Instead it would be applied after the data came back from the database.  When you wanted to revert to automatically generated SQL you would hit the RESET button.

In current versions of CR the RESET button is not needed so it doesn’t normally appear.  But it will appear automatically if you open an old report that has locked SQL.  This allows you to eliminate the use of an obsolete feature.  So I checked the SQL to see if the original tweaks were still essential.  There were no UNION queries, subqueries or filters built into outer joins. So I reset the SQL and the RESET button disappeared. After that the report behaved like a normal report.









Leave a Reply

Recrystallize Pro