我正在将 mysql 数据库中的文本字段插入到 oracle clob 列中。
当我这样做时,似乎 oracle 表不支持 unicode,因为 ' 和 " 字符显示为 ???。
我必须使用 clob,因为文本字段比 varchar2 可以容纳的要大得多。
提前感谢您在此问题上提供的任何帮助。
将数据从 mysql 数据库移动到 oracle 数据库的 Perl 脚本:
sub do_crc_company_overview {
my ($sth_mysql, $sth_oracle);
my $sql_details = <<END_SQL;
select
tblRecommendations.code,
tblRecommendations.description,
tblRecommendations.overview,
tblRecommendations.performance,
tblRecommendations.updated
from
crc.tblRecommendations
where
tblRecommendations.code not in (
select
tblRecommendations.code
from
crc.tblRecommendations
where
tblRecommendations.code regexp "[0-9]"
)
END_SQL
# variables to bind values to
my ($code, $description, $overview, $performance, $updated);
eval {
# first clean out the oracle table
$sth_oracle = $dbh_oracle->prepare(q{delete from tblRecommendations});
$sth_oracle->execute;
# create oracle insertion query
$sth_oracle = $dbh_oracle->prepare(q{
insert into
tblRecommendations (
code,
description,
overview,
performance,
updated
)
values
(?, ?, ?, ?, ?)
});
# prepare our select statement for mysql
$sth_mysql = $dbh_mysql->prepare($sql_details);
$sth_mysql->execute;
$sth_mysql->bind_columns(\($code, $description, $overview, $performance, $updated));
while ( $sth_mysql->fetch ) {
# feed the data into the tblRecommendations table
# in the database, which has been cleaned out
$sth_oracle->execute($code, $description, $overview, $performance, $updated);
}
};
从 oracle 数据库中拉取数据:
class CrcCompanyInfo < Sequel::Model(IM.database[:tblRecommendations])
#Only selects companies that have one or more active instruments
set_dataset select(
:tblRecommendations__code => :code,
:tblRecommendations__description => :crc_description,
:tblRecommendations__overview => :crc_overview,
:tblRecommendations__performance => :crc_performance,
)
这很有效,因为我能够从数据库中的其他表中提取数据。
我已将其范围缩小到以下未正确通过的字符。
“ = left quote = “
†= right quote = ”
‘ = left single quote = ‘
’ = right single quote = ’
— = en dash = –
– = em dash = —
• = hyphen = -
… = ellipsis = …
我尝试在 oracle 表上进行更新以更改这些,但 oracle 表不包含有趣的键,它只是将它们全部更改为 '???' 因此更新不起作用。有人可以给我任何关于在数据输入到 oracle 数据库之前或期间如何更新数据的现场信息吗?
谢谢