How to determine if a Query has an empty result

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
sw2090
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 19.11.2007, 16:12
Location: Regensburg
Contact:

How to determine if a Query has an empty result

Post 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
diegocm
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 22.10.2007, 19:48

Post by diegocm »

Try like this:

Code: Select all

if ZQuery1.IsEmpty then
   // ...
sw2090
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 19.11.2007, 16:12
Location: Regensburg
Contact:

Post 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
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post 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.
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
Post Reply