Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: SQLite: how to get a number of rows from SELECT query

by Corion (Patriarch)
on Jul 20, 2021 at 06:00 UTC ( [id://11135193]=note: print w/replies, xml ) Need Help??


in reply to SQLite: how to get a number of rows from SELECT query

The DBI documentation states in ->execute for SELECT statements:

The execute method does not return the number of rows that will be returned by the query

So you will have to run a second query to fetch the number of returned rows, or fetch all rows to get their number.

Replies are listed 'Best First'.
Re^2: SQLite: how to get a number of rows from SELECT query
by igoryonya (Pilgrim) on Jul 20, 2021 at 07:33 UTC
    Hm, pity.
    So, it's just MySQL feature, I guess.

      As the documentation mentions (rows of DBI; look for rows under statement handle methods if that link doesn't work) it's dependent on the underlying database driver to begin with, not to mention what your query actually does. The DBD documentation may mention the behavior, too.

      Generally, you can only rely on a row count after a non-SELECT execute (for some specific operations like UPDATE and DELETE), or after fetching all the rows of a SELECT statement.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found