I'm using Perl DBD::Oracle to try and bulk insert an array of XML strings into an Oracle XMLTYPE column. I can get it to work if I bulk insert into a CLOB but when I try inserting into the XMLTYPE column via Strawberry Perl it crashes.
Has anyone being able to bulk insert into XMLTYPE from Perl?
Here are the two code snippets. One for CLOB and the second for XMLTYPE....
sub save_xml {
$log->write("Inserting XML messages into table:$table, in $mode: mode");
my @status;
my $sql='INSERT INTO ' . $table . ' (XMLCONTENT) VALUES (?)';
my $sth = $dbh->prepare_cached($sql) || die "Cannot prepare statement: $DBI::errstr";
$sth->bind_param_array(1,\@xmldocuments) || die "Cannot bind parameter array: $DBI::errstr";
$sth->execute_array({ArrayTupleStatus=>\@status}) || die "Cannot bulk insert into table: $table: $DBI::errstr";
$log->write("Inserted $status rows into table: $table");
}
sub save_xml {
$log->write("Inserting XML messages into table:$table, in $mode: mode");
my @status;
my $sql='INSERT INTO ' . $table . ' (XMLCONTENT) VALUES (?)';
my $sth = $dbh->prepare_cached($sql) || die "Cannot prepare statement: $DBI::errstr";
$sth->bind_param_array(1,\@xmldocuments,{ ora_type => ORA_XMLTYPE }) || die "Cannot bind parameter array: $DBI::errstr";
$sth->execute_array({ArrayTupleStatus=>\@status}) || die "Cannot bulk insert into table: $table: $DBI::errstr";
$log->write("Inserted $status rows into table: $table");
}