Subject | RE: [IBO] check for empty dataset |
---|---|
Author | Paul Vinkenoog |
Post date | 2004-07-26T23:51:24Z |
Hi Ronan,
FROM WHATEVER") at design time or runtime, and then, in your case:
if not MyCursor.Prepared then MyCursor.Prepare;
// don't Open a cursor; (API)First will "open" it:
MyCursor.First; // or, faster: APIFirst
if MyCursor.Eof
then ... // dataset was empty
else ... // dataset contains at least one record
Of course you can also design a singleton query like
SELECT COUNT(*) FROM ... WHERE ...
...which can be executed through a TIB_DSQL. Or (faster in case of big
datasets):
SELECT 1 FROM RDB$DATABASE WHERE EXISTS
(SELECT THISFIELD, THATFIELD FROM MYDATASET WHERE ...)
This last one returns 1 if the set contains records, NULL (not 0) if
it's empty.
Greetings,
Paul Vinkenoog
>> Use a cursor and call First and then check to see if it is EOF. IfYou use them much like Queries: assign the SQL ("SELECT BLAH1, BLAH2
>> not then just ignore the returned record.
> Thanks for your reply. Is there an example of how to use cursors
> that you can direct me towards?
FROM WHATEVER") at design time or runtime, and then, in your case:
if not MyCursor.Prepared then MyCursor.Prepare;
// don't Open a cursor; (API)First will "open" it:
MyCursor.First; // or, faster: APIFirst
if MyCursor.Eof
then ... // dataset was empty
else ... // dataset contains at least one record
Of course you can also design a singleton query like
SELECT COUNT(*) FROM ... WHERE ...
...which can be executed through a TIB_DSQL. Or (faster in case of big
datasets):
SELECT 1 FROM RDB$DATABASE WHERE EXISTS
(SELECT THISFIELD, THATFIELD FROM MYDATASET WHERE ...)
This last one returns 1 if the set contains records, NULL (not 0) if
it's empty.
Greetings,
Paul Vinkenoog