I have blob that is stored in an Oracle table that, with a chunk size of 4096 bytes, requires 2 chunks. The second chunk however is one byte long and contains a zero (ASCII 48). The data is read in using ora_lob_read, and so if you follow the method in documentation for DBD::Oracle, i.e., something like

while( my $data = $dbh->ora_lob_read( $char_locator, $offset, $chunk_size ) ) {
       print STDOUT $data;
       $offset += $chunk_size;
}

you will miss this last byte as $data will contain 0. As the data I'm interested is compressed, this causes it to be corrupted and so my code barfs later on.

I've attached a simple patch against DBD::Oracle 1.22.

Cheers,


Chris,

+++ Oracle.pm   2008-09-22 11:56:56.000000000 +0100
--- Oracle.pm.orig      2008-09-22 11:55:53.000000000 +0100
@@ -3549,9 +3549,7 @@
 
    my $chunk_size = 1034;   # Arbitrary chunk size, for example
    my $offset = 1;   # Offsets start at 1, not 0
+   while(1) {
+      my $data = $dbh->ora_lob_read( $char_locator, $offset, $chunk_size );
+      last unless length $data;
-   while( my $data = $dbh->ora_lob_read( $char_locator, $offset, $chunk_size ) 
) {
       print STDOUT $data;
       $offset += $chunk_size;
    }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to