Israel Laguna
Israel Laguna

Reputation: 1

executeUpdate in grails

I´m looking to do this with executeUpdate, the thing is concat a string value with executeUpdate in GRAILS

def transactions = Transaction.findAll()

for (tr in transactions) {
   tr.comment = tr.comment + " new words...."
   tr.save()
}

Upvotes: 0

Views: 402

Answers (2)

Rahul Mahadik
Rahul Mahadik

Reputation: 12271

   def transactions = Transaction.all  //you can use  findAll() also
    for (Transaction tr : transactions) {
       tr.comment = tr.comment + " new words...."
       tr.save(flush:true)
    }

Hope it will help you

Upvotes: 0

Demian
Demian

Reputation: 961

I have not tried but something like this

Transaction.executeUpdate("update Transaction t set t.comment=t.comment + :newComment", [newComment: 'new words...'])

OR

Transaction.executeUpdate("update Transaction t set t.comment=concat(t.comment, :newComment), [newComment: 'new words...'])

Upvotes: 1

Related Questions