Insert statement Question

I have a basic Insert statement:

INSERT INTO my_table (column_1, column_2) VALUES ('X', 'Y')

I want to insert multiple values like so:

INSERT INTO my_table (column_1, column_2) VALUES ('A', 'B'), ('C', 'D'), ('E', 'F'), ('G', 'H')

Using the given DB scripting tools, I am not sure which one to use or how I separate the multiple Values.

runPrepQuery
runPrepUpdate
runUpdateQuery

I know i can just run a loop and run 4 insert statements but i was hoping to do it in one statement.

Thanks

You just insert the entire string in runUpdateQuery:

system.db.runUpdateQuery("INSERT INTO my_table (column_1, column_2) VALUES ('A', 'B'), ('C', 'D'), ('E', 'F'), ('G', 'H')")

…or use the runPrepUpdate:

system.db.runPrepUpdate("INSERT INTO my_table (column_1, column_2) VALUES (?, ?), (?, ?), (?, ?), (?, ?)", ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'])

runPrepQuery is meant to execute only SELECT statements.

Awesome, thanks.

so i got it working with the “system.db.runUpdateQuery”, i was parsing an xml file for data building a dictionary and then converting it into a list of string inserts for the function.

Thanks again!