# Edit different rows in a table

**URL:** <https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407>\
**Category:** Ignition\
**Created:** [October 10, 2011, 5:32pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407 "2011-10-10T17:32:53Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![WEControl](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@WEControl](https://forum.inductiveautomation.com/u/WEControl)\
**Post date:** [October 13, 2011, 2:35pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/21 "2011-10-13T14:35:38Z")

</div>

I have done that but now when I try and add a row it gives me this error.

Traceback (innermost last):

File “event:actionPerformed”, line 16, in ?

java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO Customers2 (ID) VALUES (NULL), , , false)

Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Gateway Error 301: SQL error for “INSERT INTO Customers2 (ID) VALUES (NULL)”: Cannot insert the value NULL into column ‘ID’, table ‘WEDatabase.dbo.Customers2’; column does not allow nulls. INSERT fails.

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column ‘ID’, table ‘WEDatabase.dbo.Customers2’; column does not allow nulls. INSERT fails.

java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO Customers2 (ID) VALUES (NULL), , , false)

Ignition v7.2.8 (b178)  
Java: Sun Microsystems Inc. 1.6.0\_26

and you would think just change ID to allow nulls but since it is set as the primary key it wont allow nulls.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [October 13, 2011, 2:57pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/22 "2011-10-13T14:57:15Z")

</div>

im certainly no expert, but is it possible that you dont have the id column setup to auto increment?

---

<div class="post-metadata">

**Author:** ![WEControl](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@WEControl](https://forum.inductiveautomation.com/u/WEControl)\
**Post date:** [October 13, 2011, 3:07pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/23 "2011-10-13T15:07:02Z")

</div>

I do not. Not really sure how to do that. I am new to this stuff.  
I just looked at the properties of the ID column in Microsoft SQL server Management Studio 2008 and I see Identity Increment and it is set to 0 but all of the properties are all greyed out so I can’t change anything.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 13, 2011, 3:22pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/24 "2011-10-13T15:22:56Z")

</div>

Your error is telling you that table cannot take NULL values for the ID column.`"INSERT INTO Customers2 (ID) VALUES (NULL)": Cannot insert the value NULL into column 'ID', table 'WEDatabase.dbo.Customers2'; column does not allow nulls. INSERT fails.`You need to set the ID column to auto-increment if you want to insert a NULL

Each database is different, but in SQLServer Management Studio: Right-click on the table, ‘Design’ it, and click on the id column. In the properties, set the identity to be seeded @ e.g. 1 and to have increment of 1 - save and you’re done.

In MySQL Workbench: Right-click on the table, ‘Alter Table…’, and click on the columns tab. In the row for ID, set the PK and AI check boxes - apply and you’re done.

---

<div class="post-metadata">

**Author:** ![WEControl](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@WEControl](https://forum.inductiveautomation.com/u/WEControl)\
**Post date:** [October 13, 2011, 3:34pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/25 "2011-10-13T15:34:55Z")

</div>

I set the ID column seed 1 increment 1 saved and I still get the null error

---

<div class="post-metadata">

**Author:** ![WEControl](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@WEControl](https://forum.inductiveautomation.com/u/WEControl)\
**Post date:** [October 13, 2011, 3:41pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/26 "2011-10-13T15:41:32Z")

</div>

This is the properties I have set for ID and the designer.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/af162b61c3fe67f23655bdef92d090bc616bfb21.JPG)

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 13, 2011, 4:24pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/27 "2011-10-13T16:24:18Z")

</div>

That table definition looks perfect. By using an insert statement like `INSERT INTO Customers2 (ID) VALUES (NULL)`you are telling SQLServer to ignore your auto-increment and instead insert a NULL value into the ID column. Now try something like `INSERT INTO Customers2 (name) VALUES ("Joe")`

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 13, 2011, 5:43pm UTC](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407/28 "2011-10-13T17:43:23Z")

</div>

For those of you following along at home, we got this problem ironed out over the phone. The problem was a Python syntax issue, and the correct code was:`query = "INSERT INTO customers2 (name, address, phone) VALUES ('name', 'address', 'phone')"
system.db.runUpdateQuery(query)`

[Previous page](https://forum.inductiveautomation.com/t/edit-different-rows-in-a-table/3407.md?page=1)
