Perl DBI alternative to LongReadLen
Are your columns with large data LOBs (CLOBs or BLOBs)? If so, you don't need to use LongReadLen at all; DBD::Oracle provides a LOB streaming interface.
What you want to do is to bind the param as type ORA_CLOB
or ORA_BLOB
, which will get you a "LOB locator" returned from the query, instead of tex. Then you use ora_lob_read together with the LOB locator to get data. Here's an example of code that's worked for me:
sub read_lob { my ( $dbh, $clob ) = @_; my $BLOCK_SIZE = 16384; my $out; my $offset = 1; while ( my $data = $dbh->ora_lob_read( $clob, $offset, $BLOCK_SIZE ) ) { $out .= $data; $offset += $BLOCK_SIZE; } return $out;}
I think of it in this way :
use Parallel::ForkManageruse strict;# Max 50 processes for parallel data retrievingmy $pm = new Parallel::ForkManager(50);# while loop goes herewhile (my @row = $sth->fetchrow_array) {# do the fork$pm->start and next;## Data retreiving goes here## do the exit in the child process$pm->finish;}$pm->wait_all_children;
check Parallel::ForkManager in CPAN to know more.