in reply to Strange DBI/DBD::ODBC behaviour (right truncation of data on ODBC call)

Have you tried odbc_lob_read ?

poj
  • Comment on Re: Strange DBI/DBD::ODBC behaviour (right truncation of data on ODBC call)

Replies are listed 'Best First'.
Re^2: Strange DBI/DBD::ODBC behaviour (right truncation of data on ODBC call)
by jahero (Pilgrim) on Oct 22, 2019 at 11:51 UTC

    Thanks for the tip.

    I have tried it now.

    $sth = $dbh->prepare($sql); $sth->execute(); my $lob; my $chrs_or_bytes_read = $sth->odbc_lob_read(0, \$lob, 65535, { TreatA +sLOB=>1 });

    Results in .. Column 0 was not bound with TreatAsLOB

    I guess this particular DBI method can only be used on columns that are bound to a prepare statement. If that's true, it can not be used in this instance. There is nothing to bind.

    $sth = $dbh->prepare($sql); $sth->bind_col(1, \$lob); $sth->execute();
    fails with
    cannot bind to non-existent field 1

    I am sending a DDL statement (show table) into the database, and expecting to get a DDL script of the particular table as output. Everything works fine up until to a certain size of the DDL script, then I am getting the "truncation" error mentioned in the original post.

    Regards, Jan

      I can't test this on Terradata but seems to work on MSSQL

      my $sth = $dbh->prepare('select lob from table_lob'); $sth->execute(); $sth->bind_col(1, undef, {TreatAsLOB=>1}); $sth->fetch; $sth->odbc_lob_read(1, \my $data, 65335); print $data;
      poj

        Thank you for the learning opportunity, that worked.

        I need to brush my DBI skills a bit more!