Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setNumberStringFormat introduction #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

denis-salgon
Copy link

hi,
My need is to have decimal values like it are in the database without any alteration due to the approximation.
For example :
In a database number field, I could have :
249,199999999998
249,19999999998
249,1999999998
When i try to retrieved it from the database, i get in JS number
249.19999999999803
249.19999999998
249.19999999979999
Well, the result is not safe.
The most safe solution is to retrieve it as string.
So, I introduced setNumberStringFormat option for the connection object . You can set format for decimal number as "99999999999999.99999999999999" for example.

cnx.setNumberStringFormat( "99999999999999.99999999999999" );

When it is set, number value are retrieved as string without alteration :
249,19999999999800
249,19999999998000
249,19999999980000
That's allow me to transform these string values in my own javascript BCD format.
I splited integer type (Integer/smallint) from the other number types, but, it's not usefull because oracle create smallint and integer as number(38) type.
It's possible to switch off the option by assigning an empty string in format.
cnx.setNumberStringFormat("");

Thanks to watch my request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant