Perl DBI:引用函数v / s bind_params,处理大输入

时间:2016-09-07 17:53:23

标签: perl dbi freetds

想要理解语句处理程序的DBI :: quote v / s bind_params之间的区别,同时处理存储过程的大输入。

环境: Perl + DBI + FreedTDS - > SQL Server

SAMPLE CODE 1 :使用函数quote()

$xml = `cat bigfile_insrt.txt.xml.5k`; 
my $qouted = $dbh->quote($xml);
$dbh->do(qq{exec sp_toload \@XML = $qouted});

This code seems like can handle till 100MB worth of $xml

SAMPLE CODE 2 :使用bind_params作为CLOB

my $qry = "exec sp_toload \@XML = ?";
$xml = `cat bigfile_insrt.txt.xml.5k`;
my $sth = $dbh->prepare($qry);
#$sth->bind_param(1,$xml,SQL_LONGVARBINARY);
$sth->bind_param(1,$xml,SQL_CLOB);
$sth->execute();

gets truncated to 7K bytes max for $xml

想知道为什么bind_params同时SQL_LONGVARBINARY或SQL_CLOB 不能超过7K字节,而使用quote的样本1可以处理~100MB数据

0 个答案:

没有答案