Auto-formatting currency fields in Oracle

I am developing an Oracle Report. It has about 15 currency fields. The database columns from where these values are derived have datatype NUMBER(m,n).

I am formatting them in reports as follows:

SELECT TO_CHAR(field1,'99,999,999.99') --field1 datatype NUMBER(8,2)
SELECT TO_CHAR(field2,'99,999,999,999.99') --field2 datatype NUMBER(11,2)

Is there a way for Oracle to auto-format the fields based on the datatype precision of the field?

Basically I want to prevent hard-coding the '99,999,999.99'format and let Oracle do that as it already knows the precision of the field.


Source: oracle

Leave a Reply