in reply to Data export into text file
I would start by looking at DBI. Then make sure the database the information is in has a DBD::(your database here). Then a script can be written to extract the fields and with perl it can then be mangled as desired and output.
One option you didn't mention and may not have considered is that with DBI you can open 2 databases at once and read records out of one while writing the data into the other one. The databases of course can be completely different types
For example for Oracle to PostgreSQL you might go along these lines
use DBI; my $pgh=DBI->connect("DSN for Postgres here"); my $orh=DBI->connect("DSN for Oracle here"); #set up statments into variables for both eval{ my $psh=$pgh->prepare($write_stmt); my $osh=$orh->prepare($read_stmt); $osh->execute( variable list here ); $osh->bind_columns( \( $f1, $f2, $f3, ... ) ); while($osh->fetch) { $psh->execute( $f1, $f2, $f3, ... ); } $pgh->commit; } if($@) # error handler goes here { $pgh->rollback; print STDERR "Problem saving data\n"; }
Update: Fixed a type $pgh->execute should be $psh->execute. ie. use the statement handle not the DB handle for execute.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Data export into text file
by b310 (Scribe) on Mar 17, 2003 at 18:33 UTC | |
by dga (Hermit) on Mar 17, 2003 at 19:10 UTC |