On 05/09/13 20:28, Mike Grau wrote:
Hello,
I am completely new at this, but I am trying to read a BLOB in chunks
via ODBC in Oracle 11g using DBD::ODBC-1.43, unixODBC-2.3.1 and
oracle-instantclient11.2-odbc-11.2. I can read an entire BLOB in one
read and write it to the filesystem, but I really need to be able to do
it in chunks, I think.
Reading the BLOB in chunks, but I am always getting one byte less than
requested, losing the last byte, which results in a corrupt document (a
PDF) when written to the filesystem. I'm at a loss as to why this is
happening and how to correct it.
Using this snippet based on the example provided by DBD::ODBC...
while($len = $s->odbc_lob_read(1, \my $x, 8, {TYPE => 999})) {
print "len=$len, x=$x\n";
}
... produces this output:
len=7, x=435886
len=7, x=0000 n
len=7, x=0001282
len=7, x=60 0000
And a tracefile shows the same.
SQLGetData(col=1,type=-2)=1 (retlen=2046252)
<- odbc_lob_read= ( 7 ) [1 items] at /root/lob_read.pl line 45
>> odbc_lob_read DISPATCH (DBI::st=HASH(0x203c940) rc1/1 @5 g2 ima0
pid#11494) at /root/lob_read.pl line 45
-> odbc_lob_read for DBD::ODBC::st (DBI::st=HASH(0x203c940)~0x203c9d0 1
SCALAR(0x1e0a440) 8 HASH(0x203c970)) thr#1cea010
SQLGetData(col=1,type=-2)=1 (retlen=2046244)
<- odbc_lob_read= ( 7 ) [1 items] at /root/lob_read.pl line 45
>> odbc_lob_read DISPATCH (DBI::st=HASH(0x203c940) rc1/1 @5 g2 ima0
pid#11494) at /root/lob_read.pl line 45
-> odbc_lob_read for DBD::ODBC::st (DBI::st=HASH(0x203c940)~0x203c9d0 1
SCALAR(0x1e0a440) 8 HASH(0x203c9a0)) thr#1cea010
Can someone please give me some guidance how to get the full chunk
requested?
I'm using
unixODBC-2.3.1 - built from the tarball
DBD-ODBC-1.43 - installed from the tarball (perl Makefile.PL; make;
make install)
oracle-instantclient11.2-odbc-11.2.0.3 installed from RPM
DBI is the distro's perl-DBI-1.617-4.1.1.x86_64 (openSUSE 12.3)
The database and client are both x86_64
The instant client is link against libodbcinst.so.1 and unixODBC now
provides libodbcinst.so.2, so I symlinked them:
libodbcinst.so.1 -> /usr/local/lib64/libodbcinst.so.2
Ugly, but seems to work.
Ultimately I want to index documents stored in Oracle with Sphinx and so
must use ODBC. I'd like to know that this much is working before moving
on to Sphinx.
TIA -- Mike G.
Bear with me and I'll take another look at that code. If I cannot see anything
I might need to send you a new version with slightly different logging. By all
means nag me if I don't get back to you by tomorrow.
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com