running sql in grails console

/ Published in: Groovy
Save to your folder(s)

Copy this code and paste it in your HTML
  1. import groovy.sql.Sql
  2. def service = ctx.getBean("userService")
  3. def dataSource = ctx.dataSource
  4. def db = new Sql(dataSource)
  5. def result = db.rows("""(SELECT id, points FROM user WHERE points <= 100 ORDER BY points DESC LIMIT 5)""")

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.