I tried to fetch only DB value using groovy script but result includes the value along with header.
def res = con.rows("select fkuserid from tblUserCardDetail where cardValue='111633072'" )
log.info "The User ID from DB is :" + res
Result is coming like this : Mon Apr 25 06:51:07 PDT 2016:INFO:The User ID from DB is :[[fkuserid:2951]]
I want only value : 2951
When Groovy SQL returns a result, it returns it as a Map
-like object, a GroovyRowResult. Since you're using rows()
you're getting a list of GroovyRowResult
s.
If the query will always return a single record (or nothing at all), then you can use firstRow()
instead of rows()
. Then, you can access the fkuserid
property/key to get the value:
def res = con.firstRow("select fkuserid from tblUserCardDetail where cardValue='111633072'" )
log.info "The User ID from DB is :" + res.fkuserid
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句