Search code examples
oracle-databaseoracle-apex

Oracle Apex SQL in IR to compare columns and highlight the columns with differences


I have an interactive report with following query.

select db_name, db_value,db_order from db_attributes;

I need to compare all 3 columns with another table and highlight the columns which are different.

The comparison table is:

select db_name, db_value,db_order from db_attributes@db_test;

Solution

  • It looks like you have a way to identify a match that should be highlighted - here is an example of how to highlight a particular cell in an interactive report based on a condition in the report.

    • Create interactive report on the sample emp/dept data with source
    select EMPNO,
           ENAME,
           JOB,
           MGR,
           HIREDATE,
           SAL,
           COMM,
           DEPTNO,
           CASE WHEN SAL >= 3000 THEN 'Y' ELSE 'N' END MATCHED
      from EMP
    
    • Give the report a Static ID of emp

    • Create the classes: page attributes > css > insline

    .highlight {
        background-color: #E97451;
    }
    
    #emp td:has(.highlight) {
        background-color: #E97451;
    }
    

    Without the 2nd class, the text background will not fill the entire cell.

    • Set column MATCHED to "Hidden Column"
    • Set column ENAME > Column Formatting > HTML Expression to:
    {when Y/}
    <div class="highlight">#ENAME#</div>
    {otherwise/}
    <div>#ENAME#</div>
    {endcase/}
    

    This is using Template Directives

    • Result:

    enter image description here