Wednesday 15 February 2012

Using format attributes in Apex


Recently I encountered some SQL in a classic Apex report that needed some attention.

To protect the innocent, let's just say the query looked like the following:
select order_id
      ,customer_id
      ,TO_CHAR((order_total/1.1)
              ,'fm$999,999,990.00') order_total 
from demo_orders;
Sure, output looks great with the currency and all, but what happens when we try to sort using the column heading?
Works great if there is the same number of digits, but as soon as we get into lower figures, our sorting appears askew.

So how should we be doing this? With attributes defined specifically for this very purpose.
So remove any formatting out of your SQL - there should be an app attribute for that.

Here endeth the simple lesson.

Scott

No comments: