The majority of my code for accessing a Stored Procedure dataset (MS SQL Server, forward-only, readonly) is a fallback to my Clipper coding from many years ago
In code review today, I noticed a reference to IsEmpty instead in a similar block of code. Is this just a preference or is there any real difference in the example scenario?
MyStoredProc.Open;
if not MyStoredProc.IsEmpty then
begin
DoSomething;
end;
Where I usually use
MyStoredProc.Open;
if not MyStoredProc.Eof then
begin
DoSomething;
end;
Mostly because it mirrors the practice of what I use in a while loop when it's more than one record:
MyStoredProc.Open;
while not MyStoredProc.Eof then
begin
DoSomething;
MyStoredProc.Next;
end;
The IsEmpty property is for check if the dataset has records, and Eof is for check if the current record is the last. In your case if you need iterate over a dataset use eof to determine if you reach the last record.
IsEmpty
is equivalent to Bof and Eof
, not equivalent to Eof
.
In this particular case, directly after opening a new dataset it is equivalent to Eof
(because you know Bof
also holds), but in general it is not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With