on 2017 Jun 02 5:29 PM
SQLA 17.0.4 Build 2053 (also seen in 12 and 16 though) It appears that fields defined as decimal (30,6) can store more than 6 decimal places.
Take this example:
drop table if exists zMyRate; create table zMyRate ( ID integer default autoincrement, Rate dec(30,6) NOT NULL, PRIMARY KEY (ID ASC)) ; insert into zMyRate (Rate) VALUES (1.234567), (8.901234), (5.678901), (2.34567899) ; SELECT ID, Rate, cast(Rate as dec(30,8)) as ExtraDecRate FROM zMyRate; ID,Rate,ExtraDecRate 1,1.234567,1.23456700 2,8.901234,8.90123400 3,5.678901,5.67890100 4,2.345679,2.34567900
The last two digits on the fourth value are truncated during the insert as I would expect. But if you update these with a calculation that is not casted, the results are stored:
Update zMyRate set Rate = Rate * 1.3456 ; SELECT ID, Rate, cast(Rate as dec(30,8)) as ExtraDecRate FROM zMyRate; ID,Rate,ExtraDecRate 1,1.661233,1.66123336 2,11.977500,11.97750047 3,7.641529,7.64152919 4,3.156346,3.15634566
The extra decimal places are only returned if you cast the field as something defined with the extra decimals but not on the normal select as in column 2.
What is interesting is that if you alter the table and define the field as decimal (12,6), this behavior stops and the numbers are truncated in both situations - insert and update with calculation.
User | Count |
---|---|
67 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.