# Getting required precision from named query and event handler

**URL:** <https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657>\
**Category:** Ignition\
**Tags:** vision, namedqueries\
**Created:** [December 10, 2024, 8:03pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657 "2024-12-10T20:03:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Knoll](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rich_knoll/32/73001_2.png) [@Rich\_Knoll](https://forum.inductiveautomation.com/u/Rich_Knoll)\
**Post date:** [December 10, 2024, 8:03pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/1 "2024-12-10T20:03:21Z")

</div>

Hello,

I have a button that I am triggering a named query from. Here is the script:

```python
params = {
	"HardwareIDParam": int(event.source.parent.getComponent('BagIDLabel').text),
	"QuantityParam": event.source.parent.getComponent('QuantityLabel').value
		}

system.db.runNamedQuery("INSERT Inventory Transaction", params)

```

Everything works, except when I run a select query on my InventoryTransaction table, the quantity is showing as a rounded number instead of as a float with one decimal precision which is what I require. The value of the QuantityLabel is coming from a Vision Client Tag that I created of float data type. This tag is getting its value from an input on another screen. I set the datatype in the table as float as well.

Not sure what is happening here. Any guidance would be greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [December 10, 2024, 8:24pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/2 "2024-12-10T20:24:10Z")

</div>

If you can share your SQL table design and the queries, it would help.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 10, 2024, 10:59pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/3 "2024-12-10T22:59:13Z")

</div>

> [@Rich\_Knoll](#):
>
> float with one decimal precision

That's not really how floating point precision works.

E.X, there's no such thing as `0.2`, only [`0.200000000000000011102`](https://float.exposed/0x3fc999999999999a), inside the computer - and the margin of error is going to change based on how far away from zero your values are.

That probably isn't your problem here, because computers are good at lying to you about the apparent precision of numbers precisely because of this fact, but it's important to recognize. If you are dealing with, say, currency, where exact decimal math is required, _any_ floating point type is inadequate and not fit for purpose.

---

<div class="post-metadata">

**Author:** ![Rich\_Knoll](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rich_knoll/32/73001_2.png) [@Rich\_Knoll](https://forum.inductiveautomation.com/u/Rich_Knoll)\
**Post date:** [December 11, 2024, 9:00pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/4 "2024-12-11T21:00:15Z")

</div>

Hi David,

I feel a little bit silly here.

In looking up my named query so I could type a response for you, I realized that I had my quantity parameter set to a data type of Int instead of Float. I simply changed the data type and it works like I need it to 🤦‍♂️

I do think you get credit for the solution, though, since it was your question that prompted me to look closer.

Thanks!

---

<div class="post-metadata">

**Author:** ![Rich\_Knoll](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rich_knoll/32/73001_2.png) [@Rich\_Knoll](https://forum.inductiveautomation.com/u/Rich_Knoll)\
**Post date:** [December 11, 2024, 9:02pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/5 "2024-12-11T21:02:01Z")

</div>

Hi PGriffith,

This is really cool info. Didn't help me with my problem at all, but a fun little tidbit.

Thanks!

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [December 11, 2024, 9:10pm UTC](https://forum.inductiveautomation.com/t/getting-required-precision-from-named-query-and-event-handler/99657/6 "2024-12-11T21:10:01Z")

</div>

I was wondering what data types you had set up, and was hoping when you shared the information it would be indicative of the problem, looks like you found what I was going to look for, well done.
