- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Perl 脚本从数据库中提取 URL,其中使用 fetchrow_array 从数据库中提取 URL,该脚本工作正常,直到我遇到一个很长的 URL georgelog24.blog.iskreni。 net/?bid=6744d9dcf85991ed2e4b8a258153a1ab&lid=ff9963b9a798ea335b75b5f7c0c295d1
然后它开始给我这个错误。
DBD::ODBC::st fetchrow_array failed: st_fetch/SQLFetch (long truncated DBI attribute LongTruncOk not set and/or LongReadLen too small) (SQL-HY000) [state was HY000 now 01004]
[Microsoft][ODBC SQL Server Driver]String data, right truncation (SQL-01004) at C:\test\multihashtest2.pl line 44.
我相信这是在数据库方面,因为我用来提取 URL 的代码之前已经工作过。我使用的数据库是MSSQL server 2005。
数据库中的URL列当前使用text类型,但我尝试将其更改为varchar(max)和nvarchar(max) 但错误仍然存在。
经过一番尝试和错误后,我发现使用 fetchrow_array 成功查询的 url 最大长度为 81 个字符。由于 URL 有时可能会超出荒谬的长度,因此我无法对 URL 长度进行限制。
有人可以帮助我理解并建议解决这个问题吗?
仅供引用:第 44 行是下面代码中的第一行
while (($myid,$url) = $statement_handle->fetchrow_array()) { # executes as many threads as there are jobs to do
my $thread = threads->create(\&webcrawl); #initiate thread
my $tid = $thread->tid;
print " - Thread $tid started\n"; #obtain thread no. and print
push (@Threads, $thread); #push thread into array for "housekeeping" later on
}
最佳答案
尝试:
#not anymore errors if content is truncated - you don't necessarily want this
$statement_handle->{'LongTruncOk'} = 1;
#nice, hard coded constant for the length of data to be read from Longs
$statement_handle->{'LongReadLen'} = 20000;
while (($myid,$url) = $statement_handle->fetchrow_array()) { # executes as many threads as there are jobs to do
my $thread = threads->create(\&webcrawl); #initiate thread
my $tid = $thread->tid;
print " - Thread $tid started\n"; #obtain thread no. and print
push (@Threads, $thread); #push thread into array for "housekeeping" later on
}
另外,我建议您尝试Parallel::ForkManager
用于并行化作业 - 我发现它比线程更直观且易于使用
关于perl - 数据库 fetchrow_array 失败长截断 DBI 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12315397/
我在我的应用程序中使用 JDBI 和 Dropwizard。我已经使用 dbi.open 命令获取了一个 DAO 实例,然后使用它来运行各种查询。在“finally” block 中,我使用 dao.
我有一个在 eval 中运行的数据库查询,以捕获错误。问题是错误消息正在输出到控制台,即使它被困住了。如何阻止错误消息执行此操作,因为我想自己解析它并吐回我自己的消息? my $dbh = DBI->
这是我使用 DBI 的示例代码: db = DBI.connect("DBI:Mysql:database=testdatabase;host=testhost;port=30012", "testu
使用: MySQL 5.5ActivePerl v5.14.1Windows 7 64 位 以下脚本在执行调用失败时有一个未定义的 $DBI::errstr: #!c:/perl/bin/perl.e
这是整个错误 SCREAM: Error suppression ignored for ( ! ) Fatal error: Maximum execution time of 30 seconds
在Perl中捕获任何DBI错误的最佳方法是什么?例如,如果由于插入的值中包含非法字符而导致插入失败,那么如何使脚本不失败,但是如何捕获错误并进行适当处理。 我不想做“死”,因为我不想停止脚本的执行。
在工作中,我们有一个 DBA,他说他的 RAC 工作得很好,但事实并非如此。像 Toad 或 SQL Developer 这样的 SQL IDE 会随机断开它们的连接(我怀疑是因为 RAC 的网络设置
所以我有这个非常简化的片段: @cmd_arry = ("Bob Newhart", "54"); $sqlCmd = "UPDATE foobar SET name = ?, age = ?"; $
除了使用标准代码模具“无法连接:$ DBI::errstr\n”来处理错误之外,是否可以编写如下的自定义代码? 标准: $dbstore = DBI->connect($dsn, $user, $pw
假设我正在查询一个类似于以下内容的表: $dbh->selectrow_hashref('SELECT id, name FROM foos WHERE name = "bar"'); 当然,id将是
我在长时间运行的 perl 脚本中遇到了一些内存泄漏问题,其中 perl 占用的内存量继续增长。因此,我尝试使用 Devel::Leak追踪泄漏。我发现每当我调用 DBI的prepare方法,Deve
我想从表中复制一条记录,修改记录中的一些字段并插入到同一个表中。该表有 90 列。 考虑在一个语句中使用 insert..select 但有 90 列,我需要在选择查询中告诉列名。我怎样才能在 per
我有这个查询 select * from table where ID in (1,2,3,5...) 如何使用占位符使用 DBI 构建此查询? 例如 : my @list = (1, 2, 3, 4
如何使用 perl 和 fbi 针对 sql server 检索存储过程的返回值?有人可以举个例子吗? 最佳答案 DBD::ODBC t/dir 中有示例(参见 20SqlServer.t)。基本上你
实际上我已经执行了postgres查询,假设它返回了10行。现在我有了语句处理程序( $sth )。 print Dumper $sth->fetchrow_arrayref; print Dumpe
我想让 perl 在我自己的路径中使用 DBI 模块(假设,/home/users/zdd/perl5/lib/DBI),但是系统也有一个 DBI 模块,它是/usr/lib/perl5/库/DBI。
实际上我已经执行了postgres查询,假设它返回了10行。现在我有了语句处理程序( $sth )。 print Dumper $sth->fetchrow_arrayref; print Dumpe
我不熟悉在 perl 脚本中使用 DBI 进行 SQL 查询。我遇到的问题与具有正斜杠的字段中的数据有关。我想使用变量作为 where 子句的输入,但它正在做 DBI 打算用正斜杠做的事情:停止查询。
假设我有一个连接到数据库的子例程。然后我想进行查询并接收输出并对其进行处理,当然,但是如果查询无效怎么办? 所以让我们假设我有类似的东西: $dbh = DBI->connect(, , ); $qu
我正在使用 Perl 的 DBI 进行 postgreSQL 访问,我注意到当我有多个并发进程准备同一个查询时,它们似乎在服务器上以相同的准备语句名称结束,从而产生了冲突。 2014-02-10 10
我是一名优秀的程序员,十分优秀!