Prevent SQL injection
The Groovy groovy.sql.Sql class can be used to perform sanitization of SQL parameters.
<script><![CDATA[
import groovy.sql.Sql
String update = """UPDATE "ds_$transaction_ds" SET
tr_facility_id = :facilityId,
tr_deal_name = :dealName
WHERE tr_id = :transactionId""".stripIndent()
Map params = [ 'facilityId' : "$facility_id".toString(),
'dealName' : "$tr_deal_name".toString(),
'transactionId' : "$transaction_id".toString()
]
def db = dataStoreProperties.wrappedObject
def sql = Sql.newInstance (db.url, db.username, db.password)
def res = sql.executeUpdate(update, params)
log.add "Updated $res record(s)"
]]></script>