Incorrect DECIMAL value: ‘0’ for column ‘’ at row -1問題

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數據,問題就解決了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章