kubo / rust-oracle

Oracle driver for Rust
193 stars 43 forks source link

Error with oracle round function #53

Open Wukkkinz-0725 opened 2 years ago

Wukkkinz-0725 commented 2 years ago

When I try to run select round(v, 2) from test_round;, I want to get Float number result, but the return type is Number(0,0).

Number(0,0) will be parsed as Integer because the scale is 0.

test_round v 1.111 2.222 3.333

kubo commented 2 years ago

It is a documentation bug.

I should emphasize that when the precision is zero, the scale is ignored and type is NUMBER without precision and scale.

Look at the following. The data type of round(v, 2) is NUMBER.

SQL> create table test_round (v number(3, 2));

Table created.

SQL> desc test_round
 Name                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 V                          NUMBER(3,2)

SQL> insert into test_round values (1.111);

1 row created.

SQL> select round(v, 2) from test_round;

ROUND(V,2)
----------
      1.11

SQL> create table test_round_result as select round(v, 2) as rounded_v from test_round;

Table created.

SQL> desc test_round_result
 Name                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ROUNDED_V                      NUMBER