# \[SOLVED\] runPrepQuery returns no rows

**URL:** <https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365>\
**Category:** Ignition\
**Created:** [June 5, 2020, 6:06pm UTC](https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365 "2020-06-05T18:06:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 5, 2020, 6:06pm UTC](https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365/1 "2020-06-05T18:06:31Z")

</div>

Hello,  
I have the following in a function definition.

```
sql = 'SELECT column1, column2, column3 FROM table1 WHERE column4 = ?'
args = [column4_value]
tbl = system.db.runPrepQuery(sql, args, db)
return tbl

```

If my value column4\_value exists then this code returns column1, column2, column3 as a dataset with 1 row. However, if column4\_value doesn’t exist what is returned from this definition? Is it a dataset with no rows? Can I still call tbl[0][0] if there are no rows? How can I check if runPrepQuery is returning nothing?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 5, 2020, 6:30pm UTC](https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365/2 "2020-06-05T18:30:28Z")

</div>

Just tried it in scripting console. You get `<PyDataset rows:0 cols:3>`

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 5, 2020, 7:16pm UTC](https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365/3 "2020-06-05T19:16:47Z")

</div>

You can see if there is data in tbl using .getRowCount.

```auto
sql = 'SELECT column1, column2, column3 FROM table1 WHERE column4 = ?'
args = [column4_value]
tbl = system.db.runPrepQuery(sql, args, db)
if tbl.getRowCount() > 0:
    #Yeah data
    #Do something with it
return tbl

```

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 5, 2020, 8:43pm UTC](https://forum.inductiveautomation.com/t/solved-runprepquery-returns-no-rows/35365/4 "2020-06-05T20:43:49Z")

</div>

Thank you!
