# Update Query with return Value (Output)

**URL:** <https://forum.inductiveautomation.com/t/update-query-with-return-value-output/81983>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 16, 2023, 1:41pm UTC](https://forum.inductiveautomation.com/t/update-query-with-return-value-output/81983 "2023-11-16T13:41:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Spachinger](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@Thomas\_Spachinger](https://forum.inductiveautomation.com/u/Thomas_Spachinger)\
**Post date:** [November 16, 2023, 1:41pm UTC](https://forum.inductiveautomation.com/t/update-query-with-return-value-output/81983/1 "2023-11-16T13:41:43Z")

</div>

Hello,

is it possible in Ignition to execute a query from a script (in my case an insert) an get the new created row´s ID (Autoincrement) as return value from the query to work with it in the script without executing a select query later on? Like:

Insert into control  
(Name)  
OUTPUT INSERTED.controlID  
VALUES  
("'":ControlName"'")

---

<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 16, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/update-query-with-return-value-output/81983/2 "2023-11-16T13:44:13Z")

</div>

`getKey=1` as an argument should work for all the flavors of `system.db.runUpdate/Prep/NamedQuery` as long as your key is just a integer - I saw there was issues if your key is like an UUID.

You would just do `newId = system.db.runPrepUpdate("INSERT INTO Control (Name) VALUES (?)", [variableWithValue], geyKey=1)`
