# Multiple recordsets in one stored procedure

**URL:** <https://forum.inductiveautomation.com/t/multiple-recordsets-in-one-stored-procedure/12739>\
**Category:** Ignition\
**Created:** [March 1, 2017, 7:02pm UTC](https://forum.inductiveautomation.com/t/multiple-recordsets-in-one-stored-procedure/12739 "2017-03-01T19:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kraenbring](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@Kraenbring](https://forum.inductiveautomation.com/u/Kraenbring)\
**Post date:** [March 1, 2017, 7:02pm UTC](https://forum.inductiveautomation.com/t/multiple-recordsets-in-one-stored-procedure/12739/1 "2017-03-01T19:02:58Z")

</div>

I’m looking for a way to iterate through a dataset that should contain multiple recordsets.  
I have a stored procedure and it has 6 recordsets that it returns. However, all the code I’ve seen so far only allows for one recordset per call, the first one.

In other languages, you can either reference the table by index from the result or you can do a “Next Result” command and then continue on to the next dataset.

Does that technique not exist in Ignition/Python?

---

<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 1, 2017, 7:57pm UTC](https://forum.inductiveautomation.com/t/multiple-recordsets-in-one-stored-procedure/12739/2 "2017-03-01T19:57:04Z")

</div>

No. Definitely not in the client. In the gateway, you could use native JDBC, thanks to jython’s ability to use Java. You’d have to obtain a connection from the datasource’s pool, use it and return it. I’m not sure how to get the java connection purely in jython, though. /-:

---

<div class="post-metadata">

**Author:** ![Caleb\_Bohon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/caleb_bohon/32/3293_2.png) [@Caleb\_Bohon](https://forum.inductiveautomation.com/u/Caleb_Bohon)\
**Post date:** [March 2, 2017, 4:23pm UTC](https://forum.inductiveautomation.com/t/multiple-recordsets-in-one-stored-procedure/12739/3 "2017-03-02T16:23:40Z")

</div>

Kraenbring,

Could you use a different command to bring all the records into a PyDataSet or basic Dataset, then iterate through that dataset? IE use a PrepQuery function rather than a stored procedure?

I know the db functions in Ignition allow this:

Don’t use the Scalar functions as they return only one row.

```auto
data = system.db.runPrepQuery(queryString, argsList, ...)

data = system.dataset.toPyDataSet(data) #Possibly unnecessary...

for row in data:
     do something

```
