in reply to DBD::Sybase $sth->rows returns -1

I suggest you to use objects by reference (really quicker), not by value, so fetchrow_hashref or fetchall_hashref or fetch_arrayref...
my $sth = $dbh->prepare('SELECT firstname, lastname FROM user WHERE ag +e >= ? ORDER BY age desc LIMIT 200'); $sth->execute(...); my $row = undef; while ($row = $sth->fetchrow_hashref) { print $row->{ firstname }, ' ', $row->{ lastname }, "\n"; }
Rem: LIMIT the maximum rows returned, if you can.
Edit: code updated

Replies are listed 'Best First'.
Re^2: DBD::Sybase $sth->rows returns -1
by hotchiwawa (Scribe) on Jan 06, 2016 at 19:14 UTC
    Edit: it's $row->{..} not $data->{..}, I renamed the variable :/

      As a general rule, it's much better to edit or update your original post (if you're not Anonymous!) rather than to add another node which may be overlooked and which just clutters up the place. Please see How do I change/delete my post?.


      Give a man a fish:  <%-{-{-{-<

        Yep of course but it was not in the interface... now I know ;)

      FYI you can edit your post by clicking on its title.


      The way forward always starts with a minimal test.
        Your reply was helpful instead of admins bashing me with "update, edit... NOW!!!" without knowing where is the edit in the fuck* interface!

        Thanks for the tip (+1).