# Mapping Tag Values to SQL Values

**URL:** <https://forum.inductiveautomation.com/t/mapping-tag-values-to-sql-values/7731>\
**Category:** Ignition\
**Created:** [December 19, 2013, 1:33pm UTC](https://forum.inductiveautomation.com/t/mapping-tag-values-to-sql-values/7731 "2013-12-19T13:33:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [December 19, 2013, 1:33pm UTC](https://forum.inductiveautomation.com/t/mapping-tag-values-to-sql-values/7731/1 "2013-12-19T13:33:08Z")

</div>

I am trying to insert the values of some input fields into a SQL table via a Stored Procedure…

I keep getting “1st arg can’t be coerced” error, I am assuming I am running into an issue with the input values not being the same type as the SQL Fields they are going into…

Here is my call to the Stored Procedure

```auto
system.db.execSProcCall("EXEC Site.dbo.spSetTagValues @TagID = event.source.parent.getComponent('TagIDtxt').text @OrderNumber = event.source.parent.getComponent('OrdNumfld').intValue @LotNumber = event.source.parent.getComponent('LotNumtxt').text @Quantity = event.source.parent.getComponent('Qtyfld').intValue @ParentID = event.source.parent.getComponent('ParentIDtxt').text")
```

```auto
Name Ignition Data Type SQL Data Type
TagIDtxt Text NVARCHAR(50)  
OrdNumfld Value (Integer) INT
LotNumtxt Text NVARCHAR(50)
Qtyfld Value (Integer) INT
ParentIDtxt Text NVARCHAR(50)
```

I am sure I am missing something simple, just need a pointer in the correct direction… Thanks

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 19, 2013, 2:19pm UTC](https://forum.inductiveautomation.com/t/mapping-tag-values-to-sql-values/7731/2 "2013-12-19T14:19:20Z")

</div>

Hi tbackus,

You are using the system.db.execSProcCall function incorrectly. Before you can call a stored procedure with system.db.execSProcCall you have to create a stored procedure call context with system.db.createSProcCall. Have a look at the manual here: [inductiveautomation.com/support/ … occall.htm](http://inductiveautomation.com/support/usermanuals/ignition/index.html?system_db_createsproccall.htm)

It is also possible to call a stored procedure with the regular database functions such as system.db.runPrepUpdate.

---

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [December 19, 2013, 2:55pm UTC](https://forum.inductiveautomation.com/t/mapping-tag-values-to-sql-values/7731/3 "2013-12-19T14:55:21Z")

</div>

Thanks nmudge. Was realizing that shortly after posting… I think I found my solution following those examples in the manual… Anotehr case of RTFM!! 😊
