Oracle Application Express Apex
& validating numeric & currency screen items
Oracle Tips by Burleson Consulting
There are a wide variety of choices for
formatting currency items in APEX. Some of the choices you
must make for formatting APEX screen items for currency values
- Dollar Sign - You can display the
item with the dollar-sign, but your end-user may strip it off
when entering data, and you would need to write transformation
rules to ensure consistency.
- Enforcing numeric format - You
must validate that your currency item is in your desired form,
with the dollar sign and decimal point in the right places.
You can get as fancy as you want, but here is a
quick-and-dirty way to enforce a currency values using standard
APEX item validations with regular expressions. In my
example, I needed a currency screen value with a maximum value of 99
dollars and 99 cents. (Note: APEX does not have a
numeric datatype for screen items, and all screen items start as
I chose to omit the display of the dollar sign
to make it easier on my end-user, and I defined the column with a
maximum width of 5 characters, and used the APEX currency format
Upon screen item display, a visual header
reminds the end-user that the value is expressed in dollars:
Now I must enforce the 99.99 format on the
screen. Below I go into the APEX item validation wizard and
specify a regular expression for the 99.99 format as "/d/d./d/d":
Upon testing, APEX catches the formatting
error and displays a help error message to the end-user:
In sum, this is just one of many ways to
enforce numeric and currency screen item values in APEX.
Mine may not be the most sophisticated or elegant, but it works and
only takes a few minutes to code.
If you have a number with hundreds (e.g.
999.99) you can use a more sophisticated regular expression to match
a three-digit number, a decimal point, and a two-digit format for
cents, like this:
||For APEX development support just call to gat an
Oracle Certified professional for all APEX development
APEX book and code samples: