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

Error with oracle round function #53

Open
Wukkkinz-0725 opened this issue Mar 24, 2022 · 1 comment
Open

Error with oracle round function #53

Wukkkinz-0725 opened this issue Mar 24, 2022 · 1 comment

Comments

@Wukkkinz-0725
Copy link

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
Copy link
Owner

kubo commented Mar 25, 2022

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

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

No branches or pull requests

2 participants