my $dbh = DBI->connect( "dbi:Oracle:".$ENV{"ORACLE_SID"}, "u", "p", { AutoCommit => 0, # must commit or rollback transactions RaiseError => 0, # LongTruncOk => 1, # not needed, use ora_auto_lob to get # the locator instead of the lob. PrintError => 1 }); # turn on warn errors. ### get the bad image rows, status code 8 if ( defined $dbh ) { $rc = fetch_data ("SELECT imp_imh_id, imp_page_no, imp_image ". "FROM daybreak.image_pages, daybreak.image_headers ". "WHERE imh_id = imp_imh_id ". "AND imh_image_status_cd = 8" ); } $dbh->disconnect; exit; sub fetch_data { # prepare stmt handle, execute, then fetch. my ($arg); $arg = $_[0]; my $rvalue; my $hashref; my ($fil, $dir_alias, $name); my $sth = $dbh->prepare( $arg, { ora_auto_lob => 0 }) # get the lob locator or die "\nCan't prepare SQL statement:\n$DBI::errstr\n"; ### Execute the statement in the database $sth->execute or die "\nCan't execute SQL statement:\n$DBI::errstr\n"; ### Retrieve the returned rows of data while ( $hashref = $sth->fetchrow_hashref() ) { print STDERR "FETCH: $hashref->{IMP_IMH_ID}". " $hashref->{IMP_PAGE_NO}\n" if $DEBUG; my $sth2 = $dbh->prepare("BEGIN dbms_lob.filegetname". "(:fil, :dir_alias, :name); END;", { ora_auto_lob => 0 }) # get the lob locator or die "\nCan't prepare SQL statement:\n$DBI::errstr\n"; $fil = ${ $hashref->{IMP_IMAGE} }; ######## ERROR OCCURS HERE $sth2->bind_param(":fil", $fil, { ora_type => ORA_BLOB } ); $sth2->bind_param_inout(":dir_alias", \$dir_alias, 100); $sth2->bind_param_inout(":name", \$name, 100); $sth2->execute or die "\nCan't execute SQL statement:\n$DBI::errstr\n"; } warn "\nData fetching terminated early by error:\n$DBI::errstr\n" if $DBI::err; return $rvalue; }