How do you add rows retrieved from database to an arraylist (of objects?) in Groovy? -
selectstatement = 'select * table' try { // eachrow method iterator sql.eachrow( selectstatement ) { //need add results arraylist row row. each object in //arraylist must contain : id, description, code, isdefault. have //access values calling ${it.skill_id}, ${it.description}, //${it.skill_code}, ${it.is_default}. id int, description , code //strings , default bit } } catch (e) { }
also if can me iterating on elements of arraylist until match code.
thank you,
wouldn't rows
give want?
now try query using rows:
def rows = sql.rows("select * project name 'gra%'") assert rows.size() == 2 println rows.join('\n')
with output this:
[id:20, name:grails, url:http://grails.org] [id:40, name:gradle, url:http://gradle.org]
Comments
Post a Comment