【问题标题】:DBD::mysql::st execute failed: called with 181 bind variables when 172 are neededDBD::mysql::st 执行失败:需要 172 时使用 181 绑定变量调用
【发布时间】:2016-10-30 15:47:15
【问题描述】:

我收到了这个错误

DBD::mysql::st execute failed: called with 181 bind variables when 172 are needed at line 110, <$fh> line 1.

我认为问题出在这部分代码

while ( my $row = <$fh> ) {

    chomp $row;

    my @DNA = split('\|', $row);  

    my $participant_id = $DNA[0];
    $participant_id =~ s/\>//g;

    my $array = $DNA[1];

    my $length = length $array;

    $array =~ tr/a-z/A-Z/;
    $array =~ s/(...)/$1 /g; 
    $array =~ s/\s+/,/g;

    my @DNA1 =   split (',', $array);
    unshift @DNA1, $participant_id;

    $sth4->execute(@DNA1);  # Line 110  
}

$sth4->finish;

【问题讨论】:

  • 有用的错误信息。您的@DNA 的列数比相应的 SQL 语句所知道的要多。查找 SQL 语句的定义位置(在代码中进一步查找 $sth4),看看您是否能弄清楚该做什么。您可能需要更改 SQL 以适应您的数据大小。
  • 您可以通过打开跟踪查看它尝试运行的 SQL:stackoverflow.com/questions/5885561/…
  • 谢谢@xxfelixxx,这给了我继续前进的动力。

标签: mysql perl bioinformatics


【解决方案1】:

使用 172 个占位符,我假设 SQL 语句是自动生成的

您需要查看类似的代码

my $sth4 = $dbh->prepare(...);

其中包含 172 个占位符 ? 而您的声明

my @DNA1 = split (',', $array);

导致@DNA1 有 181 个元素

问题出在这几行

$array =~ tr/a-z/A-Z/;
$array =~ s/(...)/$1 /g; 
$array =~ s/\s+/,/g;

这显然不是你认为的那样

显示$array 的内容(在一个新问题中)并描述您真正需要的转换,我们将能够提供帮助

顺便说一句,这些都是一些糟糕的变量名。 $array 显然不是一个数组,@DBA1 只是一些 .. 数据库列表 .. 东西,并且没有充分的理由使用大写字母

【讨论】:

    猜你喜欢
    • 2023-04-11
    • 2020-06-01
    • 2014-07-14
    • 1970-01-01
    • 2019-07-07
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多