# SQL Query Binding question

**URL:** <https://forum.inductiveautomation.com/t/sql-query-binding-question/17395>\
**Category:** Ignition\
**Created:** [March 16, 2018, 7:36pm UTC](https://forum.inductiveautomation.com/t/sql-query-binding-question/17395 "2018-03-16T19:36:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [March 16, 2018, 7:36pm UTC](https://forum.inductiveautomation.com/t/sql-query-binding-question/17395/1 "2018-03-16T19:36:12Z")

</div>

I have a label’s text field bound to a SQL query. The query is below:

```auto
select recipe_running
from furnace_loads
where id = {Root Container.Equipment Schedule.selectedEvent}

```

The id value is being supplied by a component property of an Equipment Schedule component. The SQL query works as expected when there’s an event actually selected, but ignition is throwing up an error when the form loads. This is because the selectedEvent is a null value at that point (nothing selected on the equipment schedule component). This causes the database to error on the query.

Is there a way to disable the query from running if the .selectedEvent property is empty? Or to supply a dummy variable inside the SQL query binding?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 16, 2018, 7:39pm UTC](https://forum.inductiveautomation.com/t/sql-query-binding-question/17395/2 "2018-03-16T19:39:52Z")

</div>

Create an integer custom property and use the [coalesce expression function](https://docs.inductiveautomation.com/display/DOC79/coalesce) to convert the null to a dummy integer.

---

<div class="post-metadata">

**Author:** ![Brian](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Brian](https://forum.inductiveautomation.com/u/Brian)\
**Post date:** [March 16, 2018, 7:44pm UTC](https://forum.inductiveautomation.com/t/sql-query-binding-question/17395/3 "2018-03-16T19:44:15Z")

</div>

That’s working, thanks!
