in reply to small cgi output problem

Using DBD::Oracle, I consistently get $sth->rows returning 0 even when there's data for it. The reason that is, consulting the documentation, is that rows reliably returns the number of rows affected by a statement that *modifies* data, not on SELECT ones:

For `SELECT' statements, it is generally not possible
to know how many rows will be returned except by
fetching them all.  Some drivers will return the
number of rows the application has fetched so far, but
others may return -1 until all rows have been fetched.
So use of the `rows' method or `$DBI::rows' with
`SELECT' statements is not recommended.
You'll just have to count 'em manually, looks like.

HTH

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Replies are listed 'Best First'.
Re: Re: small cgi output problem
by suaveant (Parson) on Apr 09, 2001 at 20:56 UTC
    Of course, I guess the question here is, how do you know if there were no rows returned... without causing an error... or should you just try to catch the error.
                    - Ant
      Pragmatically speaking, if there are no rows returned, the fetch*() call won't loop very many times. (Assuming 'zero' is akin to 'not very many').

      The practical approach would be to issue a SELECT COUNT(*) query, which makes the database do the counting.

        whats the correct syntax in perl for that selection with regard to the $sth5 selection step
        With the MySQL DBI it will allow you to call fetchrow forever if nothing is returned. Throwing errors.
                        - Ant