in reply to Re^2: DBD::Sybase $sth->rows returns -1
in thread DBD::Sybase $sth->rows returns -1

Thank you for your suggestion poj.

I am using while loop to get all the fetched records. In select queries I am using your suggestion where ever possible or else writing another query with select count(*)

But even in case of UPDATE queries I am getting -1 for $sth->rows and trying to figure out how to handle that.

  • Comment on Re^3: DBD::Sybase $sth->rows returns -1

Replies are listed 'Best First'.
Re^4: DBD::Sybase $sth->rows returns -1
by poj (Abbot) on Jan 07, 2016 at 14:07 UTC

    For non-select statements you could use

    my $rowCount = $dbh->do($statement);

    see do

    poj
Re^4: DBD::Sybase $sth->rows returns -1
by hotchiwawa (Scribe) on Jan 07, 2016 at 09:15 UTC
    Please remove the COMMIT and give a feedback ;)

    Edit
    Please change your execute with this one :)
    $sth18->execute($userName) or die "Couldn't execute statement: " . $st +h18->errstr;
    Execute returns a true value if it succeeds and a false value otherwise, so we abort if for some reason the execution fails.

    Another important thing is that Rows method is database-driver specific, so it might not work in other drivers, or it might work differently in other drivers.