33๐
As @sivakumar-r mentioned above, itโs the precision and scale issue.
Letโs see how the Numeric(precision, scale)
works:
Suppose, if we have a column defined with NUMERIC(10,3)
.
This means, we can only save 10 digits in total with 3 spaces after decimal point.
So the range you can save in this case is:
+9999999.999 to -9999999.999.
One Solution Could be:
Alter table column to use type NUMERIC
without the precision and scale.
This will accept up to 131072 digits before the decimal point; up to 16383 digits after the decimal point. As mentioned in postgres:11 Numeric types document.
3๐
Earlier you had decimal number like Number(300, 100). I think you have some data in this decimal field. Now you alter the decimal field to Number(10,2). So now you can only save max 99999999.99. But your old data is much more than this. Because earlier you can save decimal number of 300 max digits and 100 decimal places.
- [Django]-The QuerySet value for an exact lookup must be limited to one result using slicing. Filter error
- [Django]-Django-Forms with json fields
- [Django]-How do I deploy Django on AWS?
1๐
Reproduce this postgresql error:
ERROR: numeric field overflow
A field with precision 5, scale 4 must round to an absolute
value less than 10^1
Create a postgresql table with a column with type: numeric(4,4)
then try to insert data from another table that has a numeric(5,4)
column type:
CREATE TABLE mytable( mycolumn numeric(5,4));
insert into mytable values(12.3456);
CREATE TABLE mytable2( mycolumn numeric(4,4));
insert into mytable2 ( select * from mytable ); --Error thrown here
Solution
Increase the space allotted to the numeric column receiving the data or define a custom cast function to make the number fit into its destination.
- [Django]-Get list item dynamically in django templates
- [Django]-How can I get MINIO access and secret key?
- [Django]-Django Generic Views using decorator login_required