# Execute Stored Procedure

**URL:** <https://forum.inductiveautomation.com/t/execute-stored-procedure/2715>\
**Category:** Archived Topics\
**Created:** [March 3, 2011, 4:46pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715 "2011-03-03T16:46:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrtweaver](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mrtweaver](https://forum.inductiveautomation.com/u/mrtweaver)\
**Post date:** [March 3, 2011, 4:46pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/1 "2011-03-03T16:46:24Z")

</div>

Ok how do I execute a stored procedure in FSQL and pass along a variable with it?

I know in FPMI you use the exec ‘proc name’ ‘variables’

Of course without the quotes, but when I try that in FSQL it gives an error.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 3, 2011, 5:21pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/2 "2011-03-03T17:21:38Z")

</div>

Where are you trying that query? On a expression item?

---

<div class="post-metadata">

**Author:** ![mrtweaver](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mrtweaver](https://forum.inductiveautomation.com/u/mrtweaver)\
**Post date:** [March 3, 2011, 5:25pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/3 "2011-03-03T17:25:25Z")

</div>

Action Item Configuration  
SQL Query radial button checked

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 3, 2011, 5:29pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/4 "2011-03-03T17:29:33Z")

</div>

What is the error you are getting?

---

<div class="post-metadata">

**Author:** ![mrtweaver](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mrtweaver](https://forum.inductiveautomation.com/u/mrtweaver)\
**Post date:** [March 3, 2011, 5:37pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/5 "2011-03-03T17:37:06Z")

</div>

It will not allow me to save the query.

I have tried

executeQuery(exec proc\_name {variable})  
exec proc\_name {variable}  
exec proc\_name ‘{variable}’  
executeQuery(exec proc\_name) notice without variable just to see if it would save it

While it does save some variations most times it says a statement error has occured do you wish to continue.

So what is the correct format for calling a stored procedure from within Factory SQL in the Action Item Configuration section?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 3, 2011, 6:57pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/6 "2011-03-03T18:57:56Z")

</div>

Well, the query must be in double quotes like:`executeQuery(concat("exec proc_name ", {variable}))`

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [March 3, 2011, 7:38pm UTC](https://forum.inductiveautomation.com/t/execute-stored-procedure/2715/7 "2011-03-03T19:38:30Z")

</div>

> [@](#):
>
> SQL Query radial button checked

Travis' response is correct, if you have the "expression" mode selected. With "SQL Query" mode, you should be able to use simply:

```auto
exec proc_name {tag}
```

As Travis asked, what error does it give you when you click OK? The only thing I can get to come up is that the referenced item doesn't exist, if I use a name that doesn't exist in the group.

Regards,
