# How to add new rows to a table using Ignition's Pespective Text Field Component

**URL:** <https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [September 1, 2023, 6:34pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685 "2023-09-01T18:34:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wendy\_Minai](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@Wendy\_Minai](https://forum.inductiveautomation.com/u/Wendy_Minai)\
**Post date:** [September 1, 2023, 6:34pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/1 "2023-09-01T18:34:42Z")

</div>

I have an empty SQL table called Plt65\_Supply\_Room.  
I want to create a user interface such that people can add new rows into my table.  
How can i manage this?  
Below code it what I have on my Configure events srcipt section on mouce click 'ENTER' Button.  
Please help

 ![text field trial](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/8/18d99971858a47cfd775c2f0524b98ec2096ab4c.png)

```auto
def runAction(self, event):
		
		ItemName = self.getSibling("Item Name").props.text
		Department = self.getSibling("Department").props.text
		Alias = self.getSibling("Alias").props.text
		Notes = self.getSibling("Notes").props.text
		Equipment = self.getSibling("Equipment").props.text
		OEM_PN = self.getSibling("OEM PN").props.text
		Shaw_PN = self.getSibling("Shaw PN").props.text
		
		system.db.runPrepUpdate("INSERT INTO Plt65_Supply_Room ([Item_Name], [Department], [Alias], [Notes], [Equipment], [OEM PN], [Shaw PN]) Values(?,?,?,?,?)",[ItemName, Department, Alias, Notes, Equipment, OEM_PN, Shaw_PN])
		
		self.getSibling("Item Name").props.text = ''
		self.getSibling("Department").props.text = ''
		self.getSibling("Alias").props.text = ''
		self.getSibling("Notes").props.text = ''
		self.getSibling("Equipment").props.text = ''
		self.getSibling("OEM PN").props.text = ''
		self.getSibling("Shaw PN").props.text = ''
		

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 1, 2023, 6:43pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/2 "2023-09-01T18:43:27Z")

</div>

You need to have the same number of question marks as you have items (You only have 5 vs 7).

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [September 1, 2023, 7:04pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/3 "2023-09-01T19:04:34Z")

</div>

I find it easier breaking it down, easier to read.

```auto
	query = "INSERT INTO Plt65_Supply_Room (Item_Name, Department, Alias, Notes, Equipment, OEM PN, Shaw PN) VALUES (?,?,?,?,?,?,?)"
	args = [ItemName, Department, Alias, Notes, Equipment, OEM_PN, Shaw_PN]
	system.db.runPrepUpdate(query, args)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 1, 2023, 7:10pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/4 "2023-09-01T19:10:16Z")

</div>

I agree, but I don't like trying to count the `?` so I let the code do it for me.

```auto
args = [ItemName, Department, Alias, Notes, Equipment, OEM_PN, Shaw_PN]
query = """INSERT INTO Plt65_Supply_Room 
		(Item_Name, Department, Alias, Notes, Equipment, OEM PN, Shaw PN) 
		VALUES ({})"""
query.format(','.join(['?'] * len(args)))
system.db.runPrepUpdate(query, args)

```

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [September 1, 2023, 7:16pm UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/5 "2023-09-01T19:16:21Z")

</div>

Wasn't aware of that one, that's good to know. I cant remember the last time my insert query worked first time, to check the logs to see I was a ? missing.

Thankyou.

---

<div class="post-metadata">

**Author:** ![Wendy\_Minai1](https://avatars.discourse-cdn.com/v4/letter/w/cdc98d/32.png) [@Wendy\_Minai1](https://forum.inductiveautomation.com/u/Wendy_Minai1)\
**Post date:** [September 2, 2023, 2:41am UTC](https://forum.inductiveautomation.com/t/how-to-add-new-rows-to-a-table-using-ignitions-pespective-text-field-component/78685/6 "2023-09-02T02:41:34Z")

</div>

@lrose thank you for that tip.
