Hello,

We connect to an iSeries AS400 using DBI and DBD::ODBC on a RHEL6 64-bit
web server. Since upgrading to a 64-bit server, we've had trouble with
outer joins that return NULLs (when there is no corresponding record on the
joined table).

select a.PRSK01, b.PSTA15
    from TESTHA.POLMAST a
    left join TESTHA.P15POLDP b
    on a.POLC01 = b.PPOL16
where POLC01 = 3950136

This statement generates a "long truncated DBI attribute LongTruncOk not
set and/or LongReadLen too small)" error. A DBI trace shows that the
datalen of column #2 is being set to 429467295 (0xffffffff) instead of -1:

    bind_columns fbh=ba55a0 fields=2
    Bind 1: type = CHAR(1), buf=c35940, buflen=4
    Bind 2: type = CHAR(1), buf=c35944, buflen=3
    bind_columns=0
    SQLFetch=0
    fetch num_fields=2
    fetch col#1 PRSK01 datalen=1 displ=4
    '2'(1)
    fetch col#2 PSTA15 datalen=4294967295 displ=3
    !!dbd_error2(err_rc=-999, what=st_fetch/SQLFetch (long truncated DBI
attribute LongTruncOk not set and/or LongReadLen too small),
handles=(bdfef0,be0600,c4e040)
    !SQLError(bdfef0,be0600,c4e040) = (HY000, 1, st_fetch/SQLFetch (long
truncated DBI attribute LongTruncOk not set and/or LongReadLen too small))

I can work around the error in ODBC::DBD by setting the datalen to -1 in
dbdimp.c, but I'm hoping there is a better solution.

        if (DBIc_TRACE(imp_sth, DBD_TRACING, 0, 4))
            PerlIO_printf(
                DBIc_LOGPIO(imp_dbh),
                "    fetch col#%d %s datalen=%ld displ=%lu\n",
                i+1, fbh->ColName, (long)fbh->datalen,
                (unsigned long)fbh->ColDisplaySize);

if (fbh->datalen == 0xffffffff) {
  fbh->datalen = -1;
 }

        if (fbh->datalen == SQL_NULL_DATA) {    /* NULL value        */
            SvOK_off(sv);
            continue;
        }

This error does not occur using isql, which is part of unixOBDC.

Any hints to how I can better fix this issue?

Thanks,
Keith Carangelo

-- 
http://www.kcaran.com

Reply via email to