-1

我正在尝试从 oracle db 检索数据,但得到 No such property: expected for class: Script1343 (in groovy script); 错误

import java.util.Properties;
import java.io.InputStream;
import groovy.sql.Sql;

def url = 'jdbc:oracle:thin:@//localhost:1521/TEST'
def user = 'DB'
def password = 'DB'
def driver = 'oracle.jdbc.driver.OracleDriver'
def sql = Sql.newInstance('url', 'User',     'password','oracle.jdbc.driver.OracleDriver')
sql.withStatement { 
   stmt -> stmt.queryTimeout = 30
   print "Request TimeOut"
} 

def rowNum = 0
sql.eachRow("SELECT DISTINCT CST_START_DT_PF,CST_ITEM_NUM_PF  FROM COST "){     row ->
  def first = row[0]
  def middle = row.CST_START_DT_PF
  def one = row.CST_ITEM_NUM_PF
  assert expected[rowNum] == "$CST_START_DT_PF, $CST_ITEM_NUM_PF" 
}
4

1 回答 1

2

有几件事是错误的。您询问的具体错误是以下结果:

assert expected[rowNum] == "$CST_START_DT_PF, $CST_ITEM_NUM_PF"

您正在引用一个expected不存在的变量。

你没有问下面的事情,但你会遇到其他问题......

引用$CST_START_DT_PF并且$CST_ITEM_NUM_PF将成为一个问题,因为它们也不存在,至少不是以您的代码可以工作的方式。

您也可能会得到与您从不递增的事实相关的意外结果rowNum

于 2017-02-27T19:19:08.623 回答