question about to_char

35 views
Skip to first unread message

Gmail

unread,
Jul 22, 2022, 11:59:21 AM7/22/22
to h2-da...@googlegroups.com
Hi,

I am using H2 2.1.214.

the following :

select to_char(2E+1,'9999D00') from dual;
------
|2E+1|
------

select to_char(.0000001+2E+1,'9999D00') from dual;

------------
|20.0000001|
------------

Should the first select not give 20.00 as result ?

Kind regards

Willy

Evgenij Ryazanov

unread,
Jul 22, 2022, 10:12:41 PM7/22/22
to H2 Database
Hello!

Yes, it's a bug. Implementation of this Oracle compatibility function doesn't handle DECFLOAT arguments properly, but you can cast them to a some other numeric types as a workaround.

TO_CHAR(CAST(2E+1 AS NUMERIC(6, 2)), '9999D00')

Approximate numeric literals (with exponent) have DECFLOAT data type in new versions of H2.
Reply all
Reply to author
Forward
0 new messages