# INSERT INTO table Error

**URL:** <https://forum.inductiveautomation.com/t/insert-into-table-error/79180>\
**Category:** Ignition\
**Created:** [September 14, 2023, 6:33pm UTC](https://forum.inductiveautomation.com/t/insert-into-table-error/79180 "2023-09-14T18:33:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_Ibarra](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jesus\_Ibarra](https://forum.inductiveautomation.com/u/Jesus_Ibarra)\
**Post date:** [September 14, 2023, 6:33pm UTC](https://forum.inductiveautomation.com/t/insert-into-table-error/79180/1 "2023-09-14T18:33:25Z")

</div>

Hi!!

I´m having some problems with my script , i am using **system.db.runPrepUpdate** in order to insert new information into my table but every time that the script is been executing my table is updated with the same information 4 times  
My script looks like this:

```auto
`Preformatted text`Producidas =event.source.value
Cantidad = event.source.parent.getComponent('Numeric Label').value
DateDN=event.source.parent.getComponent('Popup Calendar').date
PartNum =event.source.parent.getComponent('Label 6').text
Sec = event.source.parent.getComponent('Label 7').text
Machine = event.source.parent.Maquina

if Producidas == Cantidad :
	system.db.runPrepUpdate("INSERT INTO ProductionComplete (PartNum,Sec,Cantidad, Estacion, Producidas, Fecha_produccion)VALUES(?,?,?,?,?,?)",[PartNum,Sec,Cantidad,Maquina,Producidas,DateDN])
	event.source.parent.getComponent('Button').visible = 1

```

---

<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:** [September 14, 2023, 7:16pm UTC](https://forum.inductiveautomation.com/t/insert-into-table-error/79180/2 "2023-09-14T19:16:25Z")

</div>

Nothing obvious. This is on the actionPerformed of the button? You do a `SELECT COUNT(*) FROM ProductionComplete`, write down that number, push the button, run it again, and its 4 more records? Nothing I am seeing would suggest it should be running multiple times if this is on the actionPerformed extension function.

Only other thing I think you might want to inspect  
`event.source.parent.getComponent('Button').visible = 1` - does this component maybe have a property change on it relating to it's visiblity that's also running a query? Would be odd, but anything is possible.

If you make a brand new button, paste this script in, and press it, does it also insert 4 times?
