Apologies if this is old hat... i couldn't see any bug reports for this
after a superficial search of the archive...

I am extracting a clob from an oracle database. The core blob_copy_to_file
routine enters an infinite loop by always returning a defined value in its
while loop. 
#       while(defined($self->blob_read($field, $len, $blocksize, \$buf))) {

I use a similar routine ( See blob_to_fh below; i didn't read the man page
of this undocumented method! ) and it works ok . Any thoughts?

Additionally, the blob_copy_to_file method has a 4th parameter (the buffer
size you read from the database) but the DBI prevents calling the method
with that extra argument. It might be nice to pick a buffer size that is
optimized for a particular system?

Finally, I think that it might be nice to have optimized/efficient methods
to copy a blob into a scalar and to read a blob from a filehandle
(blob_copy_to_scalar and blob_as_fh ) within the core. These are methods i
use frequently. Is anyone interested in this...?

Many thanks,

Mark.

############################################################################
############################################
sub blob_to_fh{
        my $class = shift;
        my $from = shift;
        my $sth = shift;
        my $col = shift;
        my $is_handle = (ref($from) 
                                                ? (ref($from) eq 'GLOB' ||
UNIVERSAL::isa($from,'GLOB') || UNIVERSAL::isa($from,'IO::Handle') )
                                                : (ref(\$from) eq 'GLOB')
                                        ); #that was from IO::File - whew!
        my $fh;
        if( $is_handle ){
                $fh = $from;
        }else{
                $fh = IO::File->new(">$from");
        }
        my $offset = 0;
        my $lump = 4096; # use benchmarks to get best value for you # copied
from elsewhere !
        while (1) {
                my $frag = $sth->blob_read($col, $offset, $lump);
                last unless defined $frag;
                my $len = length $frag;
                last unless $len;
                $fh->print($frag);
                $offset += $len;
        }
}
############################################################################
############################################


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of 
Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, 
proprietary copyrighted and/or legally privileged, and is intended solely for the use 
of the individual or entity named in this message.  If you are not the intended 
recipient, and have received this message in error, please immediately return this by 
e-mail and then delete it.

==============================================================================

Reply via email to