# Issues with Calling Oracle Stored procedure

**URL:** <https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903>\
**Category:** General Discussion\
**Tags:** ignition81, scripting\
**Created:** [August 20, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903 "2024-08-20T18:30:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charlie\_Boykin](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@Charlie\_Boykin](https://forum.inductiveautomation.com/u/Charlie_Boykin)\
**Post date:** [August 20, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/1 "2024-08-20T18:30:32Z")

</div>

I'm having trouble with using/calling stored procedures in Oracle DB. The stored procedure that return a data result set in table form are easy to use. I've used the database query browser with no problem. My problem is that I don't know how or if Ignition will allow me to use stored procedures with in and out parameters.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/80a23353eea6804bcae60fe201b7ce639ae6a5fd.png)  
How do I use this stored procedure using the script console in Ignition?

---

<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:** [August 20, 2024, 6:33pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/2 "2024-08-20T18:33:30Z")

</div>

Start here:

> **[system.db.createSProcCall | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-db/system-db-createSProcCall)**
>
> Creates an SProcCall object, which is a stored procedure call context.

---

<div class="post-metadata">

**Author:** ![Charlie\_Boykin](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@Charlie\_Boykin](https://forum.inductiveautomation.com/u/Charlie_Boykin)\
**Post date:** [August 20, 2024, 8:07pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/3 "2024-08-20T20:07:16Z")

</div>

I don't know if I have the syntax correct or not.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/a/6af771c8a7dddfd7af3f83d40ec7400555baccca.png)

---

<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:** [August 20, 2024, 8:13pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/4 "2024-08-20T20:13:16Z")

</div>

The syntax error is improper indentation. Spaces matter to python. Look at the red squiggly mark at the point of the error.

I doubt you will be able to return an Oracle cursor.

---

<div class="post-metadata">

**Author:** ![flexware](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/flexware/32/66243_2.png) [@flexware](https://forum.inductiveautomation.com/u/flexware)\
**Post date:** [August 20, 2024, 11:08pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/5 "2024-08-20T23:08:59Z")

</div>

Another way we've done this many many times using SQL Server procedures was to just put your `EXEC` statement into a named query.

So, an example of calling an MSSQL procedure will look something like this:

```sql
EXEC [schema].[procedureName]
    @paramName1 = :ParamName1,
    @paramName2 = :ParamName2,
    ...
    @paramNameN = :ParamNameN

```

where `:ParamNameN` is a Named Query parameter.

I'm not familiar at all with Oracle DB, but I would venture to guess you can probably use a similar strategy?

---

<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:** [August 21, 2024, 12:19am UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/6 "2024-08-21T00:19:11Z")

</div>

> [@flexware](#):
>
> use a similar strategy?

Not for out or inout parameters.

---

<div class="post-metadata">

**Author:** ![flexware](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/flexware/32/66243_2.png) [@flexware](https://forum.inductiveautomation.com/u/flexware)\
**Post date:** [August 21, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/7 "2024-08-21T14:52:44Z")

</div>

If there are many output parameters, I agree - there isn't really a way to return them. But what does work in SQL Server is something like

```sql
-- could also be a table
DECLARE @myVar BIGINT;

EXEC [schema].[procedureName]
    @paramName1 = :ParamName1,
    @paramName2 = :ParamName2,
    ...
    @paramNameN = @myVar -- @paramNameN is OUTPUT

SELECT @myVar;
-- or SELECT * FROM @myVar; if @myVar is a table

```

Then you would set the query type based on if you return one value or many. This doesn't really answer the Oracle question, but is a SQL Server equivalent

---

<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:** [August 21, 2024, 3:06pm UTC](https://forum.inductiveautomation.com/t/issues-with-calling-oracle-stored-procedure/94903/8 "2024-08-21T15:06:43Z")

</div>

> [@flexware](#):
>
> But what does work in SQL Server is something like

I avoid brand-specific functionality. You are using a SQL _ **script** _. Vanilla JDBC only explicitly supports SQL _ **statements** _. Some JDBC drivers support scripts, but they only work by accident in Ignition.

And Ignition will seriously screw up your NQ if you have a colon-delimited parameter embedded in a SQL comment.

I strongly recommend you **not** use this technique, to protect your future self from changes in JDBC drivers and/or Ignition implementation details.

(Comments, DECLARE, conditional blocks, and any use of @ parameters are features of SQL scripts. Do not use them from Ignition. If you absolutely need a script, define it entirely in the database.)
