SXSQ0004: SQL INSERT failed
Added by Anonymous almost 16 years ago
Legacy ID: #5757502 Legacy Poster: Shalom Carmel (scarmel)
Hi, a strange problem. I am trying to update a DB2 on iSeries table by saxon-sql. The database table contains a 1 character column. Inserts to the database that refer this column fail with error SXSQ0004: SQL INSERT failed: Data truncation When I alter the column to use 2 characters, the insert works like a charm. Other database columns are being filled up with no problem. I tried to change the xml encoding to ASCII, but to no avail. The data length is exactly one character. Constants fail too. Shalom
Replies (2)
RE: SXSQ0004: SQL INSERT failed - Added by Anonymous almost 16 years ago
Legacy ID: #5757827 Legacy Poster: Michael Kay (mhkay)
There's a self-confessed "hack" in the code here: (SQLInsert line 191) // another hack: setString() doesn't seem to like single-character string values if (val.length()==1) val += " "; //System.err.println("Set statement parameter " + i + " to " + val); ps.setObject(i++, val); So if you supply a single-character item, it looks as if it automatically adds a space to change it to 2 chars, which I guess is going to fail if the column only accepts one character. Really, this code needs to be enhanced to look at the type definitions in the database schema. I don't know how significant a job that is, but I'm disinclined to take it on - the SQL extension is largely user-contributed code and my thinking is to keep it that way, if only because I don't have the resources to test against a large variety of databases.
RE: SXSQ0004: SQL INSERT failed - Added by Anonymous almost 16 years ago
Legacy ID: #5770732 Legacy Poster: Shalom Carmel (scarmel)
lol, this is weird. Can you think of a reason for this logic?
Please register to reply