将空值绑定到准备好的语句中

时间:2016-08-18 15:48:25

标签: sql groovy null sybase

我有这段代码:

String updText = "update table set varcharPar=?, floatPar=?, datePar=?, intPar=? where id=7"

def updateCounts = sql.withBatch(1, updText) { ps ->
    def args = [Types.NULL, Types.NULL, Types.NULL, Types.NULL]
    ps.addBatch(args)
}

当我尝试更新时,它不能使用varchar参数,给我

Caught: java.sql.BatchUpdateException: Implicit conversion 
from datatype 'INT' to 'VARCHAR' is not allowed. 
Use the CONVERT function to run this query.

适用于int,float和date。我怎么解决这个问题?

如果我把null而不是Types.NULL,它不适用于float。

0 个答案:

没有答案
相关问题