# How to check whether Database Transaction completed or not?

**URL:** <https://forum.inductiveautomation.com/t/how-to-check-whether-database-transaction-completed-or-not/5118>\
**Category:** Ignition\
**Created:** [September 7, 2012, 5:03pm UTC](https://forum.inductiveautomation.com/t/how-to-check-whether-database-transaction-completed-or-not/5118 "2012-09-07T17:03:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skallepalli](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@skallepalli](https://forum.inductiveautomation.com/u/skallepalli)\
**Post date:** [September 7, 2012, 5:03pm UTC](https://forum.inductiveautomation.com/t/how-to-check-whether-database-transaction-completed-or-not/5118/1 "2012-09-07T17:03:49Z")

</div>

Dear Inductive Team,

We need to load multiple datasets in a single Event, one dataset based on another datset result. Example:

`
vDS1 = system.db.runQuery("SELECT * FROM Table1;")
vValue1 = vDS1.getValueAt(2, 0)
vDS2 = system.db.runQuery("SELECT * FROM Table2 WHERE Col1 = %s;"%(vValue1))
.
.
.
`When we run this code, all lines will try to run same time or will not wait for First Query to be completed. And it will rise “vDS1 does not exist”.

How to make sure once first query is completed then only we need to run second query ? We hope our question is clear.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [September 7, 2012, 5:14pm UTC](https://forum.inductiveautomation.com/t/how-to-check-whether-database-transaction-completed-or-not/5118/2 "2012-09-07T17:14:15Z")

</div>

I think the issue here is system.db.runQuery() returns a PyDataSet, and getValueAt() only works with Dataset. Try this instead:

`vDS1 = system.db.runQuery("SELECT * FROM Table1;")
vValue1 = vDS1[2][0]
vDS2 = system.db.runQuery("SELECT * FROM Table2 WHERE Col1 = %s;"%(vValue1))`

---

<div class="post-metadata">

**Author:** ![skallepalli](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@skallepalli](https://forum.inductiveautomation.com/u/skallepalli)\
**Post date:** [September 12, 2012, 11:31am UTC](https://forum.inductiveautomation.com/t/how-to-check-whether-database-transaction-completed-or-not/5118/3 "2012-09-12T11:31:10Z")

</div>

Thanks James.

We got solution for our issue. Our logic working fine now.
