In Groovy, I want to be able to execute a truncate query dynamically. However, I know the following won't work as ${s}.${x}
needs to be interpolated before being sent to sql.execute
. But what is the best and safest method to be able to run the below?
for (String s : schema) {
for (String x : table) {
try {
sql.execute "TRUNCATE ${s}.${x}" ;
} catch (Exception e) {
println e
}
}
}