# SQL Stored Procedure Parameters

**URL:** <https://forum.inductiveautomation.com/t/sql-stored-procedure-parameters/5873>\
**Category:** Ignition\
**Created:** [February 14, 2013, 9:18pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-parameters/5873 "2013-02-14T21:18:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaepark](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaepark](https://forum.inductiveautomation.com/u/jaepark)\
**Post date:** [February 14, 2013, 9:18pm UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-parameters/5873/1 "2013-02-14T21:18:32Z")

</div>

Hello

I have a stored procedure in SQL Server 2008. I am using the Ignition version 7.5.5 b1255

sp\_AddValues  
@ID AS int,  
@val1 AS int = null,  
@val2 AS int = null

## INSERT SomeTable (ID, val1, val2) VALUES (@ID, val1, val2)

I try running the following through script.  
call=system.db.createSProcCall(“sp\_AddValues”)  
call.registerInParam(“MultID”,system.db.INT,1)   
call.registerInParam(“val2”,system.db.DECIMAL,3)

I receive the following error:  
caused by Exception: Error executing system.db.execSProcCall()  
caused by GatewayException: The index 3 is out of range.  
caused by SQLServerException: The index 3 is out of range.

However the following works  
call=system.db.createSProcCall(“sp\_AddValues”)  
call.registerInParam(“MultID”,system.db.INT,1)   
call.registerInParam(“val1”,system.db.DECIMAL,2)

Why do I need to specify the val1 parameter, when I only need val2 and val1 is not required?

---

<div class="post-metadata">

**Author:** ![Michael.Stofan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.stofan/32/3342_2.png) [@Michael.Stofan](https://forum.inductiveautomation.com/u/Michael.Stofan)\
**Post date:** [February 15, 2013, 12:38am UTC](https://forum.inductiveautomation.com/t/sql-stored-procedure-parameters/5873/2 "2013-02-15T00:38:04Z")

</div>

I’m pretty sure the parameters are 0-indexed, which means the numbering scheme will start at 0. That would explain why param 3 is being reported as ‘out of bounds’. Try running the procedure like this:

call=system.db.createSProcCall(“sp\_AddValues”)  
call.registerInParam(“MultID”,system.db.INT,0)   
call.registerInParam(“val1”,system.db.DECIMAL,2)
