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

It might be worth taking advantage of the three-argument open, lexically scoped filehandles and the automatic closure of same when they go out of scope. So instead of your

{ local $/; open SQLFILE, "< file.sql" or die "Can't open file.sql: $!"; $stmts = <SQLFILE>; close SQLFILE; }

you could do

my $stmts = do { local $/; open my $sqlFH, q{<}, q{file.sql} or die qq{open: file.sql: $!\ +n}; <$sqlFH>; };

I hope this is of interest.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^5: how could i insert data from a file to oracle database
by koleti (Novice) on Nov 13, 2007 at 16:40 UTC
    it did not worked can you suggest any other way.
      What specifically did not work? Can you post some output and the code you tried? I'd be glad to look it over.

      ---
      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.

        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.