这是出于测试目的(自动测试)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)
我没有找到任何地方明确的答案,所以我把它们拼凑在一起。
希望这有助于某人
答案 0 :(得分: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字符串中