Friday, 15 August 2025

Oracle APEX: "Number Field" Issue for Large numbers



The Issue

Recently I bumped into an issue with Oracle APEX page item with "Number field" type. 

It simply does not work if the page item contains large number as a value, such as workspace ID or a primary key value generated by SYS_GUID (related to Quick SQL tables and triggers generation).

https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SYS_GUID.html

https://docs.oracle.com/en/database/oracle/apex/23.1/aeutl/configuring-quick-sql-settings.html

So what is the issue?

During the item validation APEX displays the invalid number error EVEN if the number IS valid

Like on the screenshot below, where I entered a workspace ID and tried to submit the page.


BTW - I'm using the latest APEX version 24.2 at the moment 

Also, when I manually updated the value in the database table using SQLCl client and opened the page I also had an issue. Page was not loaded correctly.

Why is this issue happening?

I noticed a marker of JavaScript error in the developer bar and investigated an error:


It seems that the number is too big for JavaScript to handle?!

I checked the documentation and the largest number value that JavaScript can handle is 9007199254740991 and my Workspace ID value 43001042883076577 is much larger than that.

During the page load while the large number value was already in the table (updated via SQLCl client) I also got a JavaScript error.

When this issue started to happen?

Originally, I developed an application in APEX version 19.2 and there I had no issues. Large numbers were handled flawlessly and I was able to enter a workspace ID and submit the page. Data validation also worked well in case that I haven't entered a valid number.

But then I installed the application on another environment with latest APEX 24.2 and got this issue.

I was curious when this issue started to happen... somewhere between versions 19.2 and 24.2. 

So I started digging and figured out that APEX 21.1 introduced some number item enhancements like on-the-fly formatting and client side validation. You may check the following URL and the official release notes document (page 17):

https://www.oracle.com/a/otn/docs/apex-211-new-features.pdf

The client side implementation required JavaScript to be used and JavaScript has this number size limitation I already mentioned in previous chapter. 

What to do with this issue - a solution

Well, the simplest solution is to use an ordinary text item field instead of number item field.

Regarding a data validation, it can be done on a server-side as a ordinary APEX validation after the submit and before processing. There is a validation type "Item is numeric" and You may apply it on ordinary text field. Like this:




Pros - You may enter the large number and also validate an entered value 
Cons - There is no on-the-fly number formatting.

So, if You can survive without  the on-the-fly number formatting then this is a way to go. Otherwise You need to implement a solution by Yourself. (JavaScript supports big integer values) or search for an appropriate plugin. Maybe You can find something on apex.world website.