The Oracle APEX Guide Oracle Apex Guide RSS Feed


How to use PL SQL Decode to Display Report Icons

The decode function has the functionality of an IF-THEN-ELSE statement. The syntax for the decode function is:

decode ( expression , search , result [, search , result]... [, default] )

  • expression is the value to compare.
  • search is the value that is compared against expression.
  • result is the value returned, if expression is equal to search.
  • default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).

See Screen 1 for an example PL SQL Decode statement in Oracle APEX...

decode(HEADS_OF_TERMS_DOC, NULL, '<img src="&TU12IMAGES.cross.gif" alt="Not Available">', '<a target="_blank" href="&WEBSERVER.'||REFERENCE||'/L/'||HEADS_OF_TERMS_DOC||'"><img src="&TU12IMAGES.tick.gif" alt="'||HEADS_OF_TERMS_DOC||'"></a>') "HEADS_OF_TERMS_DOC",

This decode statement is equivalent to the following IF-THEN-ELSE statement:


'<img src="&TU12IMAGES.cross.gif" alt="Not Available">';


'<a target="_blank" href="&WEBSERVER.'||REFERENCE||'/L/'||HEADS_OF_TERMS_DOC||'"><img src="&TU12IMAGES.tick.gif" alt="'||HEADS_OF_TERMS_DOC||'"></a>'


The result is a report as show in Screen 2 with a display of a red cross icon if no document is available and a green tick icon if a document is available (with a document URL hyperlink).


PL SQL Decode statements in Oracle APEX
Screen 1
Page Top

Oracle APEX report with display of icons
Screen 2
Page Top

© RuleWorks - All Rights Reserved - Policy - - Sitemap