How do I know how many rows a Perl DBI query returns?

后端 未结 7 848
遥遥无期
遥遥无期 2020-12-15 18:51

I\'m trying to basically do a search through the database with Perl to tell if there is an item with a certain ID. This search can return no rows, but it can also return one

7条回答
  •  庸人自扰
    2020-12-15 19:11

    Change select to always return something? This should work in Sybase, dunno about other DBs.

    my $th = $dbh->prepare(qq{SELECT count(*) FROM bounce_info WHERE bi_exim_id = '$exid'});
    $th->execute();
    if ($th->fetch()->[0]) {
    ....
    }
    

提交回复
热议问题