Page 1 of 1

How to determine if a Query has an empty result

Posted: 19.11.2007, 16:19
by sw2090
I have a simple question but i don't get that figured out :(
I have a ZQuery and i open it. Now not to run into trouble I need to check if that query has an empty result (if so the code that uses the result must not be run).
How do I do that?
ZQuery.EmptyDataSet, ZQuery.FieldCount and ZQuery.RecordCound were tried without success so far.
Unfortunately I don't find documentation so far so maybe that could be due to wrong logic .

who can help me?

Sebastian

Posted: 19.11.2007, 16:49
by diegocm
Try like this:

Code: Select all

if ZQuery1.IsEmpty then
   // ...

Posted: 19.11.2007, 16:50
by sw2090
it turned out to be somewhat xcrossport bug in lazarus.
I used ZQuery.RecordCount <> 0 on linux and it works fine. After publishing that project und moving it to my windows box und compiling it with windows lazarus (same version) it works fine there too.
So I say its not a ZeosLib issue...

cheers
Sebastian

Posted: 20.11.2007, 13:45
by gto
BTW, using ZQuery.RecordCount <> 0 is quite slow than ZQuery.IsEmpty on large datasets.

RecordCount method always count all rows, which mean they're fetched. IsEmpty, as long I remember, just look for any row, trying to not fetch.