# getId with Named Queries

**URL:** <https://forum.inductiveautomation.com/t/getid-with-named-queries/18444>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [June 13, 2018, 1:56pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444 "2018-06-13T13:56:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amarth](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarth/32/3313_2.png) [@Amarth](https://forum.inductiveautomation.com/u/Amarth)\
**Post date:** [June 13, 2018, 1:56pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444/1 "2018-06-13T13:56:13Z")

</div>

Hello all,

Is it possible to retrieve the last insterted id (INSERT Query) by using the Named Queries ?

It was possible to do this with the “Old Style” queries by setting the parameter getKey to 1 but I can’t find anything similar with the Named queries.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [June 13, 2018, 2:24pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444/2 "2018-06-13T14:24:24Z")

</div>

It’s not currently an option with Named Queries but it is on the list. getKey is a fantastic feature!

---

<div class="post-metadata">

**Author:** ![bwhite](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bwhite/32/7112_2.png) [@bwhite](https://forum.inductiveautomation.com/u/bwhite)\
**Post date:** [August 8, 2023, 1:57pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444/4 "2023-08-08T13:57:27Z")

</div>

Is there any update on this? If not, what is the trick to getting the last inserted id? Run another named query?

---

<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:** [August 8, 2023, 1:58pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444/5 "2023-08-08T13:58:35Z")

</div>

`newId = system.db.runNamedQuery('someInsertQuery', {'param1':'someParam'}, getKey=1)`

There is a getKey kwarg now.

---

<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:** [August 8, 2023, 1:59pm UTC](https://forum.inductiveautomation.com/t/getid-with-named-queries/18444/6 "2023-08-08T13:59:22Z")

</div>

Manual listing:

[https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery](https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery)
