我正在寫一個perl腳本來更新oracle數據庫中的表與mysql數據庫中的數據。perl使用來自另一個數據庫的值更新oracle數據庫
我是新來的Perl,所以任何幫助,將不勝感激。
我目前有以下不更新oracle數據庫,但也不會引發任何錯誤。
數據庫已經初始化。
我想oracle tblrecommendations表的性能更新mysql tblrecommendations表中的內容。
在此先感謝。
#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 ([email protected]) {
# what went wrong
push (@errors, "Unable to update company details: [email protected]");
# rollback our transaction
$dbh_oracle->rollback()
}
$sth_oracle->finish if ($sth_oracle);
$sth_mysql->finish if ($sth_mysql);
}
感謝這工作:) – JordanC