getId with Named Queries

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.

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

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

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

There is a getKey kwarg now.

3 Likes

Manual listing:

https://docs.inductiveautomation.com/display/DOC81/system.db.runNamedQuery

2 Likes