# SQL Stored Procedure Encapsilation

**URL:** <https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 5, 2022, 5:16pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692 "2022-01-05T17:16:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [January 5, 2022, 5:16pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692/1 "2022-01-05T17:16:43Z")

</div>

I’m working a a vendor’s documentation that demonstrates calling a stored procedure in a way that I’m not familiar with. I would like to encapsulate the call in a custom script in the project and then use that script throughout the project. Can anyone suggest how this would look like in Ignition scripting? I have worked with stored procedures in Ignition before and I reviewed the Ignition documentation but am a little perplexed reconciling the Ignition stored procedure call with the variable types that the code example provides.

 ![dataHub.PNG](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/a/6a9b18fba33b7bed9a714fa8c5463b8a797b2f22.jpeg)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 5, 2022, 5:22pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692/2 "2022-01-05T17:22:38Z")

</div>

There’s unfortunately a lot of ceremony involved with stored procedure calls (due to the way JDBC works) but the manual page for `createSProcCall` should get you started:  
[https://docs.inductiveautomation.com/display/DOC81/system.db.createSProcCall](https://docs.inductiveautomation.com/display/DOC81/system.db.createSProcCall)  
[https://docs.inductiveautomation.com/display/DOC81/system.db.execSProcCall](https://docs.inductiveautomation.com/display/DOC81/system.db.execSProcCall)

The gist is that you create the stored procedure call “object” with `create`, then you register your parameters (and the values you’re going to supply), then you `exec` the stored procedure.

---

<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 5, 2022, 5:48pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692/3 "2022-01-05T17:48:55Z")

</div>

You may be toast. I’m not familiar with any generic JDBC way to deliver complex data to your procedure like that. I could do it with pure PostgreSQL connection, so I’m sure it **can** be done, but possibly not with Ignition’s infrastructure.

---

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [January 5, 2022, 5:51pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692/4 "2022-01-05T17:51:40Z")

</div>

Thanks for the reply. Is there a datatype for NULL because documents I cannot see it. For example, if the value in python that I want to send to the call is None then I want to register a NULL value for the variable type.

---

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [January 5, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-encapsilation/54692/5 "2022-01-05T17:52:44Z")

</div>

It appears so. I will likely have to encapsulate the stored procedure call inside another stored procedure on the database side.
