Successful Insert into SQL

Hi guys,
I use the runPrepUpdate to insert some data into a SQL DB using scripting but I want to be able to give the user some sort of confirmation to let them know their insert was successful, what would be the best approach? is using getKey = 1 a way to go or are there other options out there. Thanks a bunch!

getKey = 1 is good. It means that a row was successfully inserted so you get a primary key back.

Anyway, if for some reason data is not successfully inserted an exception should be thrown.

Best,

I realized this is an only thread, but I haven’t been able to find a newer one in this topic. How would you go about using the primary key you get back to drive a confirmation message?

From the manual

# This example inserts a new user and gives it the 'admin' role. Demonstrates the ability to retrieve a newly created key value.
  
# Get the username/password
name = event.source.parent.getComponent('Name').text
desc = event.source.parent.getComponent('Description').text
building = event.source.parent.getComponent('Building').selectedValue
  
# Insert the value
id = system.db.runPrepUpdate("INSERT INTO machines (machine_name, description) VALUES (?, ?)", [name, desc], getKey=1)```

#You could then use system.gui.messageBox to send the returned id to the user.