I have code like this
def myMap = [key1 : val1, key2 : val2]
sql.executeInsert("Insert into tableName(key1, key2) Values(?, ?)", myMap)
I want to create a method that will do this with any map that I pass in. As in, it should be able to create an insert statement with the correct mapping of keys to values, and most importantly be sql injection-safe. But all the examples I can find of doing inserts either aren't injection-safe or are hardcoded to particular values.
For instance, here is an example doing it in a non-injection safe way, http://www.bloggure.info/.groovy/work/quickly-insert-data-to-a-sql-database-in-groovy/