Skip to content
Advertisement

Oracle Apex conditional icons on values in classic report

I have a follow up question based on this answer which is string based: https://stackoverflow.com/a/41556608/221270

How to achieve the same conditional color and icon formatting but based on a value:

SELECT task_name,
start_date,
status,
CASE status
  WHEN > 50 THEN 'fa-clock-o is-open'
  WHEN > 100 THEN 'fa-check-circle is-closed'
  WHEN > 150 THEN 'fa-exclamation-circle is-holding'
  WHEN > 200 THEN 'fa-exclamation-triangle is-pending'
END status_icon,
CASE status
  WHEN > 10 THEN 'red'
  WHEN > 50 THEN 'green'
  WHEN > 150 THEN 'pink'
  WHEN > 200 THEN 'orange'
END icon_color,
assigned_to
FROM eba_ut_chart_tasks
ORDER BY 2

If I use the code above I got this error:

ORA-20999: Failed to parse SQL query! ORA-06550: line 10, column 1: ORA-00936: missing expression

Advertisement

Answer

The current syntax is wrong. You need to take the status column between each WHEN and THEN clauses in order to get boolean expressions such as

SELECT task_name,
       start_date,
       status,
       CASE 
         WHEN status > 50 THEN
          'fa-clock-o is-open'
         WHEN status > 100 THEN
          'fa-check-circle is-closed'
         WHEN status > 150 THEN
          'fa-exclamation-circle is-holding'
         WHEN status > 200 THEN
          'fa-exclamation-triangle is-pending'
       END status_icon,
       CASE 
         WHEN status > 10 THEN
          'red'
         WHEN status > 50 THEN
          'green'
         WHEN status > 150 THEN
          'pink'
         WHEN status > 200 THEN
          'orange'
       END icon_color,
       assigned_to
  FROM eba_ut_chart_tasks
 ORDER BY 2
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement