快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

百盛娱乐亚洲第一电子:在Grails console中执行SQL语句



1.

import groovy.sql.Sql

def dataSource= ctx.getBean('dataSource')

def sql = new Sql(dataSource)

//def ls = sql.rows(sb.toString());

sql.eachRow("select * from role"){

printl百盛娱乐亚洲第一电子n "Name is ${it.name}"

}

结果:

Name is 111

Name is 222

....

.....

================================================================

2.

import groovy.sql.Sql

def dataSource= ctx.getBean('dataSource')

def sql = new Sql(dataSource)

def sb = new St百盛娱乐亚洲第一电子ringBuffer("SELECT a.cardid, tri百盛娱乐亚洲第一电子m(a.account), trim(a.sno), trim(a.name), ")

sb

结果:

Name is 男

Name is 女

..........

=====================================================

3.

import groovy.sql.Sq百盛娱乐亚洲第一电子l

def dataSource= ctx.getBean('dataSource')

def sql = new Sql(dataSource)

def sb = new StringBuffer("SELECT a.cardid, trim(a.account), trim(a.sno), trim(a.name), "百盛娱乐亚洲第一电子)

sb

结果:

性别是男

性别是女

...........

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: