Hello,

I think you have to insert, select for update, ora_lob_write.
This is how I understand the oracle docs.
I use Ora8i and Windows at the moment, but it should be the same.
My test script does it like this:

--
  my $sth = $db->prepare( <<"  SQL" ) or die "insert $DBI::errstr";
      INSERT INTO pdf
      ( id, pdf )
      VALUES ( ?, empty_blob() )
  SQL
  $sth->execute( $lob_id ) or die "execute insert $DBI::errstr";

#  $db->commit() or die $DBI::errstr;

  $sth = $db->prepare( <<"  SQL", { ora_auto_lob => 0 } ) or die "prepare select 
$DBI::errstr";
     SELECT pdf
     FROM pdf
     WHERE id = ?
     FOR UPDATE
  SQL
  $sth->execute( $lob_id ) or die "execute select $DBI::errstr";
  my ( $bin_locator ) = $sth->fetchrow_array() or die "fetch select $DBI::errstr";
  $sth->finish();
  print "locator = $bin_locator\n";

  open BIN_FH, $ARGV[1] or die "open";
  binmode(BIN_FH);
  my $chunk_size = 4096;   # Arbitrary chunk size

  # BEGIN WRITING BIN_DATA COLUMN
   my $offset = 1;   # Offsets start at 1, not 0
   my $length = 0;
   my $buffer = '';
   while( $length = read( BIN_FH, $buffer, $chunk_size ) ) {
      $db->ora_lob_write( $bin_locator, $offset, $buffer );
      $offset += $length;
   }
#  my $buffer = '';
#  while ( read( BIN_FH, $buffer, $chunk_size ) ) {
#     $db->ora_lob_append( $bin_locator, $buffer );
#  }
  close BIN_FH;
--
  

Tuesday, May 18, 2004, 6:03:51 AM, you wrote:

PPNaml> Hi,
PPNaml> Can you tell me why 
PPNaml> "Insert into Foo values (?, EMPTY_BLOB()) returning data into ?"
PPNaml> causes a segmentation fault.
PPNaml> Where Foo is create table Foo (id integer, data blob);

PPNaml> The section of the code that runs this sql statement is
PPNaml> $stmt = "INSERT INTO Foo VALUES (?, EMPTY_BLOB()) returning the_file into
PPNaml> ?";
$sth = $dbh->>prepare($stmt);
$sth->>bind_param(1, $id);
$sth->>bind_param_inout(2, \$loc, 1000, {ora_type => ORA_BLOB});
$sth->>execute or die $dbh->errstr;

PPNaml> My perl/oracle/os/machine config is as follows:
PPNaml> Perl: 5.8.3
PPNaml> Oracle: 9i2
PPNaml> OS: GNU/Linux
PPNaml> Kernel: 2.4.18-14 
PPNaml> machine: i686
PPNaml> processor: i686 
PPNaml> hardware platform: i386 

HTH
 Wieland                            mailto:[EMAIL PROTECTED]

Reply via email to