Hi:
I'm using the "Resources" option from script runner add on. I've successfully connected to my local database and get rows from a database custom view.
Now I want to read these values to update some custom fields of issues returned in SQL query and re-index these issues, so I could search and find them with filters that use the updated custom fields.
My script is:
import com.onresolve.scriptrunner.db.DatabaseUtil
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
def c_1 = DatabaseUtil.withSql('local') { sql ->
sql.rows('select issue_id,dupu from nc_issues_pusu_v')
}
log.debug c_1
This script shows in log:
2019-09-25 02:19:59,312 DEBUG [acme.CreateSubtask]: [{ISSUE_ID=10323, DUPU=1}, {ISSUE_ID=10324, DUPU=1}] 2019-09-25 02:19:59,312 DEBUG [acme.CreateSubtask]: [{ISSUE_ID=10323, DUPU=1}, {ISSUE_ID=10324, DUPU=1}]
I want to read row by row and update the custom field "DUPU" with its value for each issue_id.
Please help me.
Regards,
Tito.