# Getting result from Oracle stored proc into dataset

**URL:** <https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 18, 2023, 5:29pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743 "2023-01-18T17:29:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.myers](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason.myers](https://forum.inductiveautomation.com/u/jason.myers)\
**Post date:** [January 18, 2023, 5:29pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743/1 "2023-01-18T17:29:29Z")

</div>

I'm in 8.1 and trying create a script to run a stored procedure in Oracle which returns SYS\_REFCURSOR datatype. I want to get the result into a dataset. I'm not sure what to put as the datatype in call.registerReturnParam() or how to get the into a dataset.

---

<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:** [January 18, 2023, 5:48pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743/2 "2023-01-18T17:48:36Z")

</div>

Pretty sure you won't be able to do that. The Oracle JDBC examples require you to register the parameter as `oracle.jdbc.OracleTypes.CURSOR`, which is not available in Ignition. (Only generic JDBC types are supported in Ignition--the actual drivers are in isolated classloaders in order to make connection pooling transparent.)

You'll probably have to wrap that procedure with another that explicitly SELECTs from that cursor. (Looks complicated--wrapping in a TABLE() function somehow. I've not used Oracle in years....)

---

<div class="post-metadata">

**Author:** ![jason.myers](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jason.myers](https://forum.inductiveautomation.com/u/jason.myers)\
**Post date:** [January 19, 2023, 2:59pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743/3 "2023-01-19T14:59:58Z")

</div>

This seems to be the correct answer. Although, I'm not sure how to do what you're suggesting. I tried changing it to output an array, but I'm not having success retrieving the data. Would you have any suggestion to point me in the right direction?

---

<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:** [January 19, 2023, 4:53pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743/4 "2023-01-19T16:53:06Z")

</div>

Sorry, I don't know enough about the TABLE() function in Oracle. If PostgreSQL, it would be trivial. 🤷‍♂️

If you can alter the procedure, arrange for it to perform the proper SELECT in the clear. That will deliver the resultset to Ignition.

---

<div class="post-metadata">

**Author:** ![martinel3746](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@martinel3746](https://forum.inductiveautomation.com/u/martinel3746)\
**Post date:** [January 19, 2023, 7:32pm UTC](https://forum.inductiveautomation.com/t/getting-result-from-oracle-stored-proc-into-dataset/68743/5 "2023-01-19T19:32:41Z")

</div>

Can you use a Stored Procedure to manage the workload in the database?  
I expect that would be much more efficient.  
My understanding of SYS\_REFCURSOR is that it's internal to the RDBMS for looping through data - I'm not sure how Ignition would instruct the cursor in Oracle to getNext() or terminate the cursor.  
If you need Ignition to loop through data, try using a NamedQuery to SELET the data and then work with the dataset.  
If you stick with system.db.runPrepQuery, you can use _system.dataset.toDataSet_ to convert a pyDataSet to a dataset if that is what you need.
