2 guoke0073 guoke0073 于 2014.04.22 15:50 提问

perl 如何存储超过4000的字段进入oracle

if ($row->{interfacetype} eq 'DATA') {
my $sth = $dbh->prepare(qq{
INSERT INTO DEV_AUDIT_RECORD (
RECORD_ID, CREATE_TIME, MEMBER_ID, AUDIT_STATE, AUDIT_TYPE, AUDIT_CONTENT, AUDIT_CONTENT_ORIGIN,
PUBLISHER_ID, PUBLISHER_NICKNAME, PUBLISHER_IP, PUBLISH_TIME,
SECTION, MESSAGE_ID, MESSAGE_ORIGIN, MESSAGE_CLASS, MESSAGE_REPRINT,
CONTENT_ID, CONTEXT_ID, CONTEXT,
ORDER_TYPE, USER_TYPE)
VALUES (
DEV_AUDIT_RECORD_ID_SEQUENCE.nextval, :create_time, :member_id, :audit_state, :audit_type,?, :audit_content_origin,
:publisher_id, :publisher_nickname, :publisher_ip, :publish_time,
:section, :message_id, :message_origin, :message_class, :message_reprint,
:content_id, :context_id, :context,
:order_type, :user_type)
RETURNING RECORD_ID INTO :record_id
});

if (!$sth or $dbh->err()) {
$logger->info($dbh->errstr());
}
else{
use utf8;
my ($commp, $dept, $product, $sub) = get_section($row->{section});
my $message_origin = encode('gbk', decode('utf-8', $product));
my $message_class = encode('gbk', decode('utf-8', $sub));
my $content_nohtml = $msg->{CONTENT};
$content_nohtml =~ s/<\/?[^>]*>//ig;
$sth->bind_param(":create_time", strftime('%Y-%m-%d %H:%M:%S', localtime()));
$sth->bind_param(":member_id", $msg->{USERID});
$sth->bind_param(":audit_state", 0);
$sth->bind_param(":audit_type", 1); #$row->{audit_type}
$sth->bind_param(":audit_content_origin", $content_nohtml);
$sth->bind_param(":publisher_id", $msg->{USERID});
$sth->bind_param(":publisher_nickname", $msg->{NICKNAME});
$sth->bind_param(":publisher_ip", $msg->{USERIP});
$sth->bind_param(":publish_time", $msg->{PUBTIME});
$sth->bind_param(":section", $row->{section});
$sth->bind_param(":message_id", $row->{messageid});
$sth->bind_param(":message_origin", $message_origin);
$sth->bind_param(":message_class", $message_class);
$sth->bind_param(":message_reprint", $row->{contenttype});
$sth->bind_param(":content_id", $msg->{CONTENTID});
$sth->bind_param(1, $msg->{CONTENT});
$sth->bind_param(":context_id", $msg->{CONTEXTID});
$sth->bind_param(":context", $msg->{CONTEXT});
$sth->bind_param(":order_type", $row->{priority});
$sth->bind_param(":user_type", $msg->{USERTYPE});
$sth->bind_param_inout(":record_id", \my $new_id, 1e17);
$sth->execute;
if ($dbh->err()) {

写入保存失败的新增数据

$logger->debug("store to the file:".$config{restoreDirectory}."/saved.dat");
#my $db = DBM::Deep->new(

file => $config{restoreDirectory}."/saved.dat",

type => DBM::Deep->TYPE_ARRAY

);

#my $len = $db->length();
#$db->put($len, $row);
$logger->error($dbh->errstr(enter code here

其中AUDIT_CONTENT为超过4000字符的字段,oracle使用的是clob。 运行报错为ORA-01461: can bind a LONG value only for insert into a LONG column (DBD ERROR: OCIStmtExecute)
查询过java在处理这个种情况的时候是调用的oracle的组件,php在处理这个情况的时候使用 php_oci扩展,问下perl在遇到这种情况下有什么解决方案,在不拆字段,不组装数据的前提下

Csdn user default icon
上传中...
上传图片
插入图片