Re: odbc_lob_read chunk is short

Mike Grau <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
Martin Gainty wrote:
> "odbc_lob_read(sth, colno, buf, length, \%attrs)
> where \%attrs can contain TYPE => SQL_type."
>
> http://www.nntp.perl.org/group/perl.dbi.dev/2010/07/msg6140.html
>
> where Type should be SQLBINARY
> http://www.nntp.perl.org/group/perl.dbi.dev/2010/09/msg6258.html

Thanks Martin,

Sorry, disregard my previous erroneous email; here's the corrected:

I've tried various incantations ...

$s->odbc_lob_read(1, \my $x, 8, {TYPE => 'SQL_BINARY'})
$s->odbc_lob_read(1, \my $x, 8, {TYPE => 'SQL_C_BINARY'})
$s->odbc_lob_read(1, \my $x, 8, {TYPE => 'SQLBINARY'})
odbc_lob_read($s, 1, \my $x, 8, {TYPE => 'SQL_BINARY'})
odbc_lob_read($s, 1, \my $x, 8, {TYPE => 'SQL_C_BINARY'})
odbc_lob_read($s, 1, \my $x, 8, {TYPE => 'SQLBINARY'})

... and the result is the same - 7 bytes are in the buffer, while the
amount yet to be read is reduced by 8.

> "It turns out I was mistaken as DBD::Oracle DOES implement blob read
> although I've not tested it works. Someone, in the distant past
> attempted an implementation in DBD::ODBC but it does NOT work and is
> seriously flawed."
> http://www.nntp.perl.org/group/perl.dbi.dev/2010/07/msg6144.html

Sorry for being thick - are you saying reading the BLOB in chunks just
isn't going to work?


I see in the trace file that ODBC thinks the type is "LONG VARBINARY"; I
set the type to SQL_BINARY in the call to odbc_lob_read:

DescribeCol column = 1, name = ATTACHMENT, namelen = 10, type = LONG
VARBINARY(-4), precision/column size = 2147483647, scale = 0, nullable = 1
     SQL_COLUMN_DISPLAY_SIZE = 2147483647
     SQL_COLUMN_LENGTH = 2147483647
     now using col 1: type = LONG VARBINARY (-4), len = 2147483647,
display size = 80, prec = 2147483647, scale = 0
    -dbd_describe done_bind=0
    have 1 fields
    -dbd_st_execute(f45808)=-1
    <- execute= ( -1 ) [1 items] at /root/lob_read.pl line 28
    >> bind_col    DISPATCH (DBI::st=HASH(0x10f4920) rc1/1 @4 g2 ima1
pid#13491) at /root/lob_read.pl line 29
    -> bind_col for DBD::ODBC::st (DBI::st=HASH(0x10f4920)~0x10f49b0 1
undef HASH(0x10f53e8)) thr#da2010
  bind_col 1 requested type:0, flags:100

-- Mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.