-1

这是出于测试目的(自动测试)SoapUI

def status = testRunner.testCase.getPropertyValue( "Status" )
def grid = testRunner.testCase.getPropertyValue( "Grid" )+"_V"
def grid1

if (["TABLE1","TABLE2"].contains(grid))
     grid1 ="HUBCFG."+grid
else grid1 = "SDM."+grid

选项1

sql.executeUpdate "UPDATE " +grid1+" t0 set XXX='$status' WHERE t0.YYY='$grid'"

选项2

String bql = "UPDATE $grid1 t0 set XXX='$status' WHERE t0.YYY='$grid'"
sql.executeUpdate bql
sql.commit()
log.info("Successfully committed "+grid1+ " To " + status)

我没有在任何地方找到明确的答案,所以我将它们拼凑在一起。

希望这可以帮助某人

4

1 回答 1

1

你应该做:

sql.executeUpdate "UPDATE ${Sql.expand(grid1)} t0 set XXX=$status WHERE t0.YYY=$grid"

或者

def bql = "UPDATE ${Sql.expand(grid1)} t0 set XXX=$status WHERE t0.YYY=$grid"

将为您添加单引号,并且 Sql.expand 允许您将诸如表名之类的内容嵌入到生成的模板化 Groovy 字符串中

于 2017-05-04T13:12:28.047 回答