Category Covered

grails manual insert sql query

Any one can let me know how to write sql insert query manually?

I have tried the following ways for manual insert query on grails but failed

 def dataSource Sql

sql = new Sql(dataSource)

sql.executeInsert("insert into ...")

 And

 import groovy.sql.Sql

sql.execute("insert into people (firstName, lastName) values ${firstName}, ${lastName})")

 

Finally I got the solutions and it works fine here, You can try this one

import groovy.sql.Sql

class BootStrap {

def dataSource

def sql = new Sql(dataSource)

sql.execute("insert into chart_class (id,  version, chart_class_type_id, name, status) values (1,1, 1, 'Assets', 1)")

}

 
Comments on "grails manual insert sql query"
Comment by, Andlib Rahman

You can try this one import groovy.sql.Sql class BootStrap { def dataSource def sql = new Sql(dataSource) sql.execute("insert into chart_class (id, version, chart_class_type_id, name, status) values (1,1, 1, 'Assets', 1)") }
Related posts