# Stored Procedure Issue - Error\_TypeConversion

**URL:** <https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056>\
**Category:** Ignition\
**Tags:** database, ignition80, scripting\
**Created:** [August 25, 2020, 2:11pm UTC](https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056 "2020-08-25T14:11:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [August 25, 2020, 2:11pm UTC](https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056/1 "2020-08-25T14:11:58Z")

</div>

Hi All,

I have an issue when a stored procedure is called from a Tag Change Event - Gateway Event Scripts.

The script is the following:

```auto
forno = '[MP4]Forni Invecchiamento/Eventi/Pw_Int_F1'[-1:] # Determino quale forno ha lanciato la script ( 1 = MF06 | 2 = MF07 )

IDFornoInvecchiamento = 'MF06'
NumeroInfornata = system.tag.readBlocking(['[MP4]Forni Invecchiamento/Pagine/Data_Recipe_String_F{}/01'.format(forno)])[0].value
DurataPrevistaMinuti = system.tag.readBlocking(['[MP4]Forni Invecchiamento/Pagine/Data_Recipe_int_F{}/08'.format(forno)])[0].value

print forno
print IDFornoInvecchiamento
print NumeroInfornata
print DurataPrevistaMinuti

# Chiamo la STORED PROCEDURE
call = system.db.createSProcCall("[dbo].[spScadaAperturaInfornata]","SomeDatabase")
call.registerInParam(1, system.db.CHAR, IDFornoInvecchiamento)
call.registerInParam(2, system.db.CHAR, NumeroInfornata)
call.registerInParam(3, system.db.SMALLINT, DurataPrevistaMinuti)
system.db.execSProcCall(call)

```

The results are:

```auto
1
MF06
MF06200814092406
330
[Error_TypeConversion("Error trying to coerce 'mf06' to a number.")]

```

I tried to use named argument names instead of indexed arguments but it’s the same.  
Ignition 8.0.9

Any help?

Cheers,

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 25, 2020, 3:33pm UTC](https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056/2 "2020-08-25T15:33:34Z")

</div>

Without the stored procedure all I can guess is that somewhere in it, you are doing an INT or number type casting of your first parameter (IDFornoInvecchiamento) which is not working given the ‘m’ in front of it. Post the stored procedure logic.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 25, 2020, 3:47pm UTC](https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056/3 "2020-08-25T15:47:18Z")

</div>

> [@c.bertulli](#):
>
> call.registerInParam(1, system.db.CHAR, IDFornoInvecchiamento)

Try passing that with quotes on it.

```auto
call.registerInParam(1, system.db.CHAR, "MF06")
```

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [August 26, 2020, 8:18am UTC](https://forum.inductiveautomation.com/t/stored-procedure-issue-error-typeconversion/38056/4 "2020-08-26T08:18:33Z")

</div>

Thanks for the support guys 🙂 but I don’t know how or why today is working 😅  
@bkarabinchak.psi inside the stored procedure there is no number type casting  
@MMaynard I tried that ( yesterday )but the same result.

Anyway, as I said, now is working.  
Thanks again for the help ❤
