# getChangedRecordData precision error?

**URL:** <https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840>\
**Category:** Classic Servoy\
**Created:** [November 6, 2008, 11:20am UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840 "2008-11-06T11:20:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![axterics](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@axterics](https://forum.servoy.com/u/axterics)\
**Post date:** [November 6, 2008, 11:20am UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/1 "2008-11-06T11:20:08Z")

</div>

If after a scripted record update I check the databaseManager.getChangedRecordData() for discover the number of update I get this for unchanged records:

(Object) BufferedDataSet{[mc,7.630000114440918,7.63][peso,186.94000244140625,186.94][ferro,155.50999450683594,155.51][trefolo,488.7699890136719,488.77][rete,181.27000427246094,181.27][mc\_cls,7.630000114440918,7.63]}

The backend DB is a MYSQL 5.0.45 with JDBC driver version 5.0.8 and all these fields are FLOAT

Servoy 4.0.1  
JDK 1.6.0\_10

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 6, 2008, 2:51pm UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/2 "2008-11-06T14:51:40Z")

</div>

FLOATs columns are tricky, are you sure you really need to use FLOATs?  
Usually the problem arises when you store decimal numbers in floats fields, Servoy writes 186.94 to the DB and the DB saves in the floating column 186.94000244140625, then Servoy thinks that there is unsaved data because the two values are different. Why you don’t just use a DECIMAL(10,2) column?

---

<div class="post-metadata">

**Author:** ![axterics](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@axterics](https://forum.servoy.com/u/axterics)\
**Post date:** [November 6, 2008, 2:58pm UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/3 "2008-11-06T14:58:25Z")

</div>

Thanks Nicola. I solve with this trick.

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 6, 2008, 3:07pm UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/4 "2008-11-06T15:07:53Z")

</div>

You’re welcome but this is not a trick, FLOATs should only be used when you need to store values with an undetermined number of decimals, basically for mathematic or geometric applications, I’ve never found the need to use them for any commercial application I’ve been working on. As a rule of thumb I think it’s always a good practice to round numeric values before writing them to the DB to prevent unexpected results. If you define a rounding strategy at least you define the precison level of your application by design, using FLOATs to handle rounding could lead you to unexpected results and to the inability of knowing the application precision level.

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 6, 2008, 4:42pm UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/5 "2008-11-06T16:42:41Z")

</div>

> could lead you to unexpected results

And get you into trouble, hours of hours spent on debugging without knowing where to look…

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 7, 2008, 8:02am UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/6 "2008-11-07T08:02:42Z")

</div>

you guys are right! but…  
if you create the column in Servoy with type Number, it will become standard a FLOAT! ![:roll:]( "Rolling Eyes")

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 7, 2008, 9:19am UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/7 "2008-11-07T09:19:27Z")

</div>

> Harjo:  
> you guys are right! but…  
> if you create the column in Servoy with type Number, it will become standard a FLOAT! ![:roll:]( "Rolling Eyes")

Not exactly, with MySQL if you create the column in Servoy as Number AND you don’t specify the lenght it will become a FLOAT (I also had my share of pain with this ![:)]( "Smile") ).  
You need to be sure to set the number of decimals you want in the lenght of the field.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 7, 2008, 10:54am UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/8 "2008-11-07T10:54:05Z")

</div>

Ah oke, that I did’nt know.

Thanks for replying that. ![:-)]( "Smile")

just to be sure, what do you fill in, if you need to store currency, with two decimals?

---

<div class="post-metadata">

**Author:** ![ngervasi](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@ngervasi](https://forum.servoy.com/u/ngervasi)\
**Post date:** [November 7, 2008, 2:59pm UTC](https://forum.servoy.com/t/getchangedrecorddata-precision-error/9840/9 "2008-11-07T14:59:33Z")

</div>

Yes, 2 decimals and I always round it before saving if there have been any \* or /
