Update Query with return Value (Output)

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"'")

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)

3 Likes