def ownerOneSql = sql.dataSet("owner_category")
ownerOneSql.add(level:1, name:oneName)
ownerOneSql.each {
println it.id + " " + it.name
}
dataSet中为表的名称,add中为要插入的数据
当有些字符串中包括了特殊字符 比如 ' ,你采用拼字符串的方式插入就报错了,可以采用上面的方式。
查询特殊字符也是,可以按照下面的方式做
def ownerOneSql = "select id from owner_category where level = 1 and name = ?"
def ownerOneId = null
sql.eachRow(ownerOneSql, [oneName]) {
ownerOneId = it.id
}
ownerOneSql.add(level:1, name:oneName)
ownerOneSql.each {
println it.id + " " + it.name
}
dataSet中为表的名称,add中为要插入的数据
当有些字符串中包括了特殊字符 比如 ' ,你采用拼字符串的方式插入就报错了,可以采用上面的方式。
查询特殊字符也是,可以按照下面的方式做
def ownerOneSql = "select id from owner_category where level = 1 and name = ?"
def ownerOneId = null
sql.eachRow(ownerOneSql, [oneName]) {
ownerOneId = it.id
}