len--;
    public void writeSQLData(XSQLDA xsqlda) throws IOException {        for (int i = 0; i < xsqlda.sqld; i++) {            XSQLVAR xsqlvar = xsqlda.sqlvar[i];            if (log != null && log.isDebugEnabled()) {                if (out == null) {                    log.debug("db.out null in writeSQLDatum");                }                if (xsqlvar.sqldata == null) {                    log.debug("sqldata null in writeSQLDatum: " + xsqlvar);                }                if (xsqlvar.sqldata == null) {                    log.debug("sqldata still null in writeSQLDatum: " + xsqlvar);                }            }            int len = xsqlda.ioLength[i];            byte[] buffer = xsqlvar.sqldata;            if (len==0) {                if (buffer != null) {                    len = buffer.length;                    writeInt(len);                    write(buffer, len, (4 - len) & 3);                    // sqlind                    write(zero, 4, 0);                }                else{                    writeInt(0);                    // sqlind                    write(minusOne, 4, 0);                }            }            else if (len < 0){                if (buffer != null) {                    write(buffer, -len, 0);                    // sqlind                    write(zero,4, 0);                }                else{                    write(textPad, -len, 0);                    // sqlind                    write(minusOne, 4, 0);                }            }            else {                if (buffer != null) {                    int buflen = buffer.length;                    if (buflen >=len){                        write(buffer, len, (4 - len) & 3);                    }                    else{                        write(buffer, buflen, 0);                        write(textPad, len- buflen, (4 - len) & 3);                    }                    // sqlind                    write(zero, 4, 0);                }                else{                    write(textPad, len, (4 - len) & 3);                    // sqlind                    write(minusOne, 4, 0);                }            }        }    }