# Update ccnum column in already created dataset

**URL:** <https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 9, 2022, 6:09pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309 "2022-11-09T18:09:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 9, 2022, 6:09pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/1 "2022-11-09T18:09:37Z")

</div>

Hi team,

I think i am stuck in somewhere didnt get any heads up.  
I have local table dataset which will have rows and having column as link, title, programid. Then i am using this data to add into our DB and it was working successfully.  
But then i need to add another column not in our local table but into db when i am sending data. I am using list function to send all dataset data into list and then to DB.  
Requesting a response asap

---

<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:** [November 9, 2022, 6:24pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/2 "2022-11-09T18:24:13Z")

</div>

1. If you need quick response, this isn't official support and you should call the support phone line.
2. Sounds like you are just trying to add a column to a database table? I would check out this -  
[SQL ALTER TABLE Statement](https://www.w3schools.com/sql/sql_alter.asp)

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 9, 2022, 6:30pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/3 "2022-11-09T18:30:57Z")

</div>

Sorry @bkarabinchak.psi my bad. Column is already added i just have to add variable value into that column. An example of the same is shown below

ccNum = "CC-42"  
#below script is used to send the data to db  
LIMSData = self.getSibling("Table\_0").props.data  
pydata = system.dataset.toPyDataSet(LIMSData)  
for index in range(len(pydata)):  
new\_ccdata = list(pydata[index])  
system.db.runPrepUpdate("INSERT INTO TableName (title, link, programid) VALUES (?, ?, ?)", new\_ccdata, "DB\_NAME")

so what i have to do is add ccnum data into CCNUm column of the same db where i am inserting table data

---

<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:** [November 9, 2022, 6:33pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/4 "2022-11-09T18:33:34Z")

</div>

Assuming it's at the end of the new\_ccdata list, add your column name just after 'programid'

EDIT: Is the new data point in the first line? If so, then you would need to append it to new\_ccdata

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 9, 2022, 6:37pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/5 "2022-11-09T18:37:19Z")

</div>

yes the new ccNum data is in first line, I have to use first line data to be inserted into table along with the insert query which i have written  
I tried append but it is not working do you have any examples of the append  
One point i missed is if 4 rows are inserted in local table then the ccNum value is to be updated on those 4 rows and not on 1 row.

---

<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:** [November 9, 2022, 7:04pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/6 "2022-11-09T19:04:49Z")

</div>

```python
ccNum = "CC-42"
#below script is used to send the data to db
LIMSData = self.getSibling("Table_0").props.data
pydata = system.dataset.toPyDataSet(LIMSData)
for index in range(len(pydata)):
	new_ccdata = list(pydata[index])
	# Append value
	new_ccdata.append(ccNum)
	# Run query. Note the extra column name and question mark.
	system.db.runPrepUpdate("INSERT INTO TableName (title, link, programid, cc_num_column_name) VALUES (?, ?, ?, ?)", new_ccdata, "DB_NAME")

```

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 9, 2022, 7:22pm UTC](https://forum.inductiveautomation.com/t/update-ccnum-column-in-already-created-dataset/66309/7 "2022-11-09T19:22:38Z")

</div>

Thanks @JordanCClark that worked as i wanted. Thanks for immediate help
