# 1) Begin the transaction. This returns a transaction identifier that we can use with other statements.
transactionId = system.db.beginTransaction(timeout = 5000)
# 2) Now we can execute statements. Because we want these to run as part of the transaction, we need to include our identifier.
query = "INSERT INTO orders (account_id, product_name) VALUES (?, ?)"
args = [123, "Bananas"]
system.db.runPrepUpdate(query, args, tx = transactionId)
# 3) We can continue to add statements, but in this case we'll commit them. We could instead rollback if there was an issue with our previous statement.
system.db.commitTransactions(transactionId)
# 4) We're done, so close the Transaction.
system.db.closeTransaction(transactionId)