in reply to Re^6: how could i insert data from a file to oracle database
in thread how could i insert data from a file to oracle database

this is what i tried
#!/usr/bin/perl
use DBI;
$user = "akoleti";
$passwd = "something";
$dbh = DBI-> connect("dbi:Oracle:host=172.31.0.87;sid=dola;port=1521", $user, $passwd) or die "Can't connect to database $DBI::errstr\n";
open( SQL, "gene_enzyme.txt") or die $!;
my @statements = <SQL>;
foreach my $stmt( @statements ){ $dbh->do($_);
}
error
DBD::Oracle::db do failed: ORA-24373: invalid length specified for statement (DB D ERROR: OCIStmtPrepare) at oracle1.pl line 12, <SQL> line 3118.
  • Comment on Re^7: how could i insert data from a file to oracle database

Replies are listed 'Best First'.
Re^8: how could i insert data from a file to oracle database
by tuxz0r (Pilgrim) on Nov 13, 2007 at 21:33 UTC
    The problem is you are still passing $_ to $dbh->do when you assign each statement to $stmt in the foreach loop. Use $dbh->do($stmt). That's what the "invalid length specified for statement" messages is about.

    ---
    echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
    Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.