Com And Hosting

Creating a dynamic field or formatting any column is quite easy using case statement in SQL query. In the recent forum post in Oracle Apex forum I have provided an example how to create dynamic URL based on the value of another field. In this example if column A has some value then create a dynamic link as column B otherwise set the column B to null. Original forum post can be found here – https://forums.oracle.com/forums/thread.jspa?messageID=10926263#10926263

Here is the example code –

SELECT CR_Number,
       CASE
          WHEN CR_NUMBER IS NOT NULL
          THEN
                '<a href="http://someurl.com?crid='
             || CR_NUMBER
             || '">'
             || CR_NUMBER
             || '</a>'
          ELSE
             NULL
       END
          AS CR_Link
  FROM table_name;

The above code is quite simple and easy to understand :).

 

Leave a Reply

Your email address will not be published. Required fields are marked *