Sorting Order in Oracle APEX Classic Report
In APEX, the sorting option for a classic report is divided into two aspects:
- How records will be sorted when the report first renders?
- Whether the end-user can change the sort order interactively by clicking the column header.
A classic report can be developed using either the static query or the dynamic query and the sorting behavior is different for both options. First, we will see the sorting behavior for the report based on the static query.
The below classic report is based on the static query and displays all the records of the EMP_DUP table. For this blog, I created EMP_DUP which is the same as the EMP table but contains duplicate records.
One thing to note here that the source query that I used in this report doesn't have an ORDER BY clause. When the report's source query has an ORDER BY clause, the records are sorted by that order only. The Sortable property will be disabled for all the columns and the end-user cannot sort the report by clicking the column header.
When you try to enable Sortable property, you will get the below error.
Now let's understand the sorting behavior for the report with dynamic query. Below is the report that I created using the dynamic query by selecting the source type Function Body returning SQL Query. Please note that the Use Generic Column Names property is disabled.
If the query returned by the function has an ORDER BY clause and the Use Generic Column Names property is disabled then the sorting behavior is the same as the sorting behavior of the static query having ORDER BY clause which implies the ORDER BY clause takes precedence and the sortable property of each column will be turned off. As you can see that the below report is sorted by EMPNO.
On the other hand, if the Use Generic Column Names property is enabled and the columns are generic, then the column's Sortable property takes precedence. The Sortable property is turned on for all the columns and the ORDER BY clause in the source query is ignored. ORDER BY clause will only take into account when the Sortable property of each column has been turned off.
Once you enabled Use Generic Column Names Property, the Column name in the rendering tree will be changed to COL01, COL02, COL03, and so on.
Comments
Post a Comment