Perl DBI Error Msg: Can't call method “selectcol_arrayref” on an undefined value

后端 未结 3 495
梦毁少年i
梦毁少年i 2021-01-26 14:50
my $dblinks = \'\';
$dblinks = $dbh->selectcol_arrayref(\"select db_link from db_links where ticket=\\\'LOW\\\'\");
my $success = 0;
for my $dblink (@$dblinks) {
  $s         


        
3条回答
  •  悲哀的现实
    2021-01-26 15:34

    my ($ret) = $dbh->selectrow_array("select 1 from " . $dbh->quote_identifier($dblink, 'SYSIBM', "SYSDUMMY1") );

    Im not an expert at DBI, but this here looks a little wierd to me. Why the single quotes around SYSIBM and double quotes around SYSDUMMY1? This probably wouldn't solve your problem, but it's a good practice. It's not manditory to Use Strict. That's a suggestion.

    $dblinks = $dbh->selectcol_arrayref("select db_link from db_links where ticket=\'LOW\'");

    This here other thing that looks really odd is the escape Slashes. I would rewrite that too. It might not work, but it sure looks good.

    $sql = qq{select db_link from db_links where ticket=LOW};

    $dblinks = $dbh->selectcol_arrayref($sql, undef);

提交回复
热议问题