I am writing a perl script to update a table in an oracle database with data from a mysql database.
I am new to perl so any help would be appreciated.
I currently have the following which does not update the oracle database but also does not throw any errors.
The databases have both been initialised.
I would like the oracle tblrecommendations table to have the performance updated with whats in the mysql tblrecommendations table.
Thanks in advance.
#transfer data
sub do_crc_company_performance {
my ($sth_mysql, $sth_oracle);
my $sql_details = <<END_SQL;
select
tblRecommendations.code,
tblRecommendations.performance
from
crc.tblRecommendations
where
length(tblRecommendations.code) = '3'
END_SQL
# variables to bind values to
my ($code, $performance);
eval {
# prepare our select statement for mysql
$sth_mysql = $dbh_mysql->prepare($sql_details);
$sth_mysql->execute;
$sth_mysql->bind_columns(\($code, $performance));
# create oracle insertion query
$sth_oracle = $dbh_oracle->prepare(q{UPDATE TBLRECOMMENDATIONS
SET PERFORMANCE = '$performance'
WHERE CODE = '$code'});
while ( $sth_mysql->fetch ) {
$performance = Encode::decode_utf8($performance); # set the flag
# feed the data into the tblRecommendations table
$sth_oracle->execute();
}
};
if ($@) {
# what went wrong
push (@errors, "Unable to update company details: $@");
# rollback our transaction
$dbh_oracle->rollback()
}
$sth_oracle->finish if ($sth_oracle);
$sth_mysql->finish if ($sth_mysql);
}