in reply to Oracle + Perl + bulk operation?
In any case, my own experience with this (in Solaris) has been that bulk inserts via DBI tend to be very slow -- actually, (so far as I know) you have to loop over inserts one row at a time; there is a notion of using a parameterize sql statement, like:
(Of course, you may need to add some better validation and some error checking...)use DBI; # I won't cover the "connect" part -- you'll need to read # docs and try things... but with $odb_handle as the # database connection object: my $sql = "insert into mytable (k,a,b,c) values (?,?,?,?)"; my $sql_handle = $odb_handle->prepare( $sql ); # suppose you're reading rows of space-separated fields # from a data file: while (<INPUT>) { @fields = split(/\s/); if ( @fields == 4 ) { $sql_handle->execute( @fields ); } }
This is fine for up to a few hundred inserts. But when you need to do a few thousand (or many hundreds at frequent intervals), you may find it goes much quicker using oracle's own "sqlload" (or is it "sqlloader"?) -- use perl to set up it's inputs and run it via a system call. I find that it not only runs many times faster, it also provides very useful error reporting (for unsuitable input and other problems that might be hard to anticipate).
As for doing selects, the DBI methods seem to perform quite well; updates may be slower, but their convenience relative to other alternatives (using oracle utilities) makes them well worthwhile.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Oracle + Perl + bulk operation?
by Ionizor (Pilgrim) on Dec 17, 2002 at 04:56 UTC |