I am using Groovy Sql to fetch results. This is the output from my Linux box.

我正在使用Groovy Sql来获取结果。这是我的Linux盒子的输出。

%isql -U abc -P abc -S support
1> sp_configure 'number of open partitions'
2> go
 Parameter Name                 Default     Memory Used Config Value    Run Value    Unit                 Type
 ------------------------------ ----------- ----------- ------------  ------------ -------------------- ----------
 number of open partitions              500        5201         5000          5000 number               dynamic

(1 row affected)
(return status = 0)
1>

I am using groovy code

我正在使用groovy代码

def sql = Sql.newInstance("jdbc:abc:sybase://harley:6011;DatabaseName=support;",dbuname,dbpassword,Driver)
sql.eachRow("sp_configure 'number of open partitions'"){ row ->
        println row.run_value
    }

but it gives me

但它给了我

Exception in thread "main" java.sql.SQLSyntaxErrorException: [abc][Sybase JDBC Driver]Invalid column name: run_value

So it says it cannot get the speciied columns, is there a way it can fetch the result and display?

所以它说它无法获取指定的列,有没有办法可以获取结果并显示?

Update

I used the below code

我使用下面的代码

sql.eachRow("sp_configure 'number of open partitions'"){ row ->
            println row
    }

and it gives me

它给了我

[Parameter Name:number of open partitions     , Default:        500, Memory Used:       5201, Config Value:        5000, Run Value:        5000, Unit:number              , Type:dynamic   ]

How can I get Run Value? (since it has a space in it)

我怎样才能获得Run Value? (因为里面有空格)

row.Run Value will not work for sure

row.Run值无法确定

2 个解决方案

#1


3

Does this work? Querying the meta-data for the column name and getting the value by index:

这有用吗?查询列名的元数据并按索引获取值:

sql.eachRow("sp_configure 'number of open partitions'"){ row ->
  (1..row.getMetaData().columnCount).each {
    println "${row.metaData().getColumnName( it )} = ${row[ it ]}"
  }
}

Or, to get the column directly

或者,直接获取列

row.'Run Value'

更多相关文章

  1. postgresql 数组 多了引号 空格处理
  2. sql2005指定字段插入空格。
  3. 在arcpy中删除或删除表的代码是什么?
  4. iBatis中sqlmap resultclass="java.lang.Integer",在代码中如何
  5. 已有SQLSERVER表如何生成其代码?
  6. PHP执行.SQL文件的实例代码分享
  7. 要在SQL数据库中根据身份证号码查询出性别(有15位的,也有18位的),怎
  8. 一条牛B的SQL抵了我300多行的程序代码
  9. Android中RecyclerView的item中控件的点击事件添加删除一行、上

随机推荐

  1. Linux基础-14day-Linux系统服务管理
  2. Chrome 74 带来的新功能[每日前端夜话0x6
  3. 杀手级的TypeScript功能:const断言[每日前
  4. 13个帮你提高开发效率的现代CSS框架[每日
  5. Android的联通性---USB的主机模式和从属
  6. 30分钟用Node.js构建一个API服务器[每日
  7. 可以用在 VS Code 中的正则表达式小技巧[
  8. 聊聊我的 2018 年
  9. 新发布的 TypeScript 3.5 RC 作出的改进
  10. Node.js 究竟是什么?[每日前端夜话0x72]