I recently updated my Go version to 1.16 and for all my queries I now get an error:
{"error":"Dynamic SQL Error\nSQL error code = -303\narithmetic exception, numeric overflow, or string truncation\nstring right truncation\n"}
func getSystem(w http.ResponseWriter, r *http.Request) {
type system struct {
Tax1 float64 `json:"tax1"`
Fees1 float64 `json:"fees1"`
Fees2 float64 `json:"fees2"`
Minus_stk string `json:"minus_stk"`
Discount1 float64 `json:"discount1"`
Discount2 float64 `json:"discount2"`
Discount3 float64 `json:"discount3"`
Discount4 float64 `json:"discount4"`
Elderly float64 `json:"elderly"`
Message NullString `json:"message"`
Binary4 NullString `json:"binary4"`
}
sysdata := []system{}
sql2 := "select tax1, fees1, fees2, minus_stk, discount1, discount2, discount3, discount4, elderly, cast(mesg as varchar(400)), binary4 from system"
conn, _ := sql.Open("firebirdsql", datapath)
defer conn.Close()
rows, err := conn.Query(sql2)
if err != nil {
respondWithError(w, http.StatusBadRequest, err.Error())
return
}
defer rows.Close()
for rows.Next() {
var p system
err := rows.Scan(&p.Tax1, &p.Fees1, &p.Fees2, &p.Minus_stk, &p.Discount1, &p.Discount2, &p.Discount3, &p.Discount4, &p.Elderly, &p.Message, &p.Binary4)
if err != nil {
respondWithError(w, http.StatusBadRequest, err.Error())
return
}
sysdata = append(sysdata, p)
}
err = rows.Err() // <--- errors seem to thrown here.
if err != nil {
respondWithError(w, http.StatusBadRequest, err.Error())
return
}
respondWithJSON(w, http.StatusOK, sysdata)
}
Your help would be appreciated.
I'm using Firebird 2.5. Everything worked under the previous version of Go. I am scanning for null values so I don't believe that is the issue.