sql转换类型是报:Incorrect DECIMAL value: ‘0’ for column ‘’ at row -1问题
根本解法:对数据输入严格校验,避免出现cast转换值为null的情况,或者对于null的情况从逻辑上进行控制
错误代码
Cause: java.sql.SQLException: Incorrect DECIMAL value: '0' for column '' at row -1
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1366]; Incorrect DECIMAL value: '0' for column '' at row -1; nested exception is java.sql.SQLException: Incorrect DECIMAL value: '0' for column '' at row -1
仔细检查数据,特别是使用cast(car_num AS DECIMAL) 函数转换的地方,表里发现car_num有一批新添加的数据为null,解决掉这批null数据,问题就解决了。