plendid has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
My goal is to copy data in one MySQL table ($bard) to one Oracle table ($pics). I believe that all but one of my lines of code are near enough okay to be okay.
$mysql_db = DBI->connect("DBI:mysql:database=$d;host=$h", $u, $) $oracle_db = DBI->connect("dbi:Oracle:host=$h;service_name=$d", $u, $p +) $mysql_db->{RaiseError} = 1; $oracle_db->{RaiseError} = 1; # get data from MySQL $sql = ' select bmprefix, bmid, englishtitle, foreigntitle from mysql_books '; $sql_handle = $mysql_db->prepare($sql); $sql_handle->execute(); $mysql_data = $sql_handle->fetchall_arrayref(); # revise Oracle table $del_sql = " delete from bard_books where bkmed = '?' and bkseq = ? "; $ins_sql = " insert into oracle_books (bkmed, bkseq, english_title, foreign_title) values ('?', ?, '?', '?') "; $del_handle = $oracle_db->prepare($del_sql); $ins_handle = $oracle_db->prepare($ins_sql);
I have a hard time with references and how to use them. It's hard to get my head around these. So this next and last statement is probably really wrong. How do i want to correct this?
$tuples = $del_handle->execute_array(\%attr, $mysql_data) or die $del_handle->errstr;
Several existing threads on perlmonks address my issue. They point to cpan modules outside DBI that are cool but a tiny bit unstable, such as DBIx::Copy.
Please accept thanks for whatever assistance or advice you're able to share.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Copying a Database Table Using DBI's execute_array
by ww (Archbishop) on May 03, 2013 at 15:18 UTC | |
by plendid (Sexton) on May 03, 2013 at 17:24 UTC | |
by karlgoethebier (Abbot) on May 03, 2013 at 17:45 UTC | |
by ww (Archbishop) on May 03, 2013 at 19:33 UTC | |
|
Re: Copying a Database Table Using DBI's execute_array
by mje (Curate) on May 08, 2013 at 13:55 UTC | |
|
Re: Copying a Database Table Using DBI's execute_array
by Anonymous Monk on May 03, 2013 at 17:46 UTC | |
by plendid (Sexton) on May 06, 2013 at 18:35 UTC |