-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Oracle NUMBER data type is formatted in an unexpected way #3596
Comments
When you use vendor-specific data types you should realize that they aren't expected to be supported by other database systems. H2 is not an emulator of Oracle and doesnt't have its special data types. You need to use some numeric data type with exact precision for this column. If it can have only integer values, you can use standard |
Thank you @katzyn. It makes sense. However, this issue didn't happen in H2 version 1. Our unit tests were suddenly failed when I updated to H2 version 2.1.214. In my opinion, |
Numeric data types preserve only the actual number. They don't preserve its textual representation.
Literals with mantissa like So it isn't surprising that conversion from |
Hi, is it possible to change the H2 internal type still to NUMERIC(H2_MAX_PRECISION, 0) when the mode is Oracle? NUMBER in Oracle becomes NUMBER(38, 0) by default as far as I know. This H2 e-notation behavior is causing too much effort in large projects. |
No, currently it isn't possible.
Try this in Oracle: CREATE TABLE TEST(N1 NUMBER, N2 NUMBER(38, 0));
> ok
INSERT INTO TEST VALUES (3.123, 3.123);
> 1 row
INSERT INTO TEST VALUES (12345678901234567890.0123456789012345678901, 12345678901234567890.0123456789012345678901);
> 1 row
INSERT INTO TEST(N) VALUES (1E45 / 7);
> 1 row
INSERT INTO TEST(N2) VALUES (1E45 / 7);
> ORA-01438: value larger than specified precision allowed for this column
SELECT * FROM TEST;
> N1 N2
> --------------------------------------------- --------------------
> 3.123 3
> 12345678901234567890.01234567890123456789 12345678901234567890
> 142857142857142857142857142857142857143000000 NULL You shouldn't use |
Thanks, fair enough. Yes indeed NUMBER without parameters in Oracle is sort of floating number. |
H2 version:
2.1.214
URL:
jdbc:h2:mem:testdb;MODE=Oracle;
SQL to reproduce:
Description: In Oracle mode, NUMBER data type is parsed in a strange and unexpected way when it is converted to a string value. If a NUMBER value contains trailing zeros, it will be formated as a scientific notation. Please see screenshot below.
The text was updated successfully, but these errors were encountered: