#1  
Old 25th February 2012, 10:28 PM
denisprince denisprince is offline
Junior Member
 
Join Date: Aug 2011
Posts: 12
Default IsEmpty when inside a range

Hi,

I've always been using IsEmpty over RecordCount for performance reasons but lately I came across this situation where IsEmpty returns false when RecordCount equals 0 when using a range. Is this a change in the implementation of TDataSet?

To show this I use a table with 2 fields, 1 integer, 1 string. I create 2 records : [1,'A'] and [2,'B'].
I add one index NoIdx field No.
With 2 cursors, TB1 with index set to SAI and TB2 with index set to NoIdx.

begin
TB1.Delete; // Delete first record index SAI
TB2.SetRange([0],[5]); // index NoIdx
EmptyTB := TB2.IsEmpty; // returns false

TB1.Delete; // Delete second record index SAI
TB2.SetRange([0],[5]);
EmptyTB := TB2.IsEmpty; // returns false!
end

Shouldn't TB2.IsEmpty return true just like TB1.IsEmpty? Does this mean that IsEmpty should not be used if a there is a range applied on the cursor?

Regards,

Denis Prince
  #2  
Old 25th February 2012, 10:57 PM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: IsEmpty when inside a range

denisprince wrote:

> Shouldn't TB2.IsEmpty return true just like TB1.IsEmpty? Does this mean
> that IsEmpty should not be used if a there is a range applied on the
> cursor?


Can you please provide a self-contained testcase (preferably using an embedded
TnxServerEngine) that shows this?
  #3  
Old 26th February 2012, 12:32 AM
Denis Prince
 
Posts: n/a
Default Re: IsEmpty when inside a range

Thorsten Engler [NDA] wrote:

> denisprince wrote:
>
> > Shouldn't TB2.IsEmpty return true just like TB1.IsEmpty? Does this
> > mean that IsEmpty should not be used if a there is a range applied
> > on the cursor?

>
> Can you please provide a self-contained testcase (preferably using an
> embedded TnxServerEngine) that shows this?


Hi Thorsten,

Testcase IsEmpty in the binaries.

Denis Prince
  #4  
Old 26th February 2012, 01:01 AM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: IsEmpty when inside a range

Denis Prince wrote:

> Hi Thorsten,
>
> Testcase IsEmpty in the binaries.


OK, everything is WAD.

IsEmpty, checks if the number of filled client side record buffers in TDataSet
is 0. This is code written by Borland/Embc in TDataSet, no NexusDB specific
code comes into play here.

SetRange is a no-op if the range values don't change. That is, if you call
SetRange a 2nd time with exactly the same values as the range that is already
active, no "Refresh" or implicit "First" is taking place. This is identical to
how TTable behaved.

After calling SetRange for the first time, the client side record buffer in the
TB2 TDataSet contains a record. Calling SetRange a 2nd time with identical
values doesn't change that. It does not perform a Refresh, so the client side
record buffers still contain the record you deleted.

If you replace the 2nd SetRange call with a call to Refresh, you will see that
IsEmpty returns true.
  #5  
Old 26th February 2012, 01:54 AM
Denis Prince
 
Posts: n/a
Default Re: IsEmpty when inside a range

Thorsten Engler [NDA] wrote:

> IsEmpty, checks if the number of filled client side record buffers in
> TDataSet is 0. This is code written by Borland/Embc in TDataSet, no
> NexusDB specific code comes into play here.
>
> SetRange is a no-op if the range values don't change. That is, if you
> call SetRange a 2nd time with exactly the same values as the range
> that is already active, no "Refresh" or implicit "First" is taking
> place. This is identical to how TTable behaved.
>
> After calling SetRange for the first time, the client side record
> buffer in the TB2 TDataSet contains a record. Calling SetRange a 2nd
> time with identical values doesn't change that. It does not perform a
> Refresh, so the client side record buffers still contain the record
> you deleted.
>
> If you replace the 2nd SetRange call with a call to Refresh, you will
> see that IsEmpty returns true.



That explains everything.

Thanks again,

Denis Prince


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RecordCount 0, IsEmpty false denisprince nexusdb.public.discussions 1 27th January 2012 10:34 PM
RecordCount 0, IsEmpty false denisprince Binaries 0 25th January 2012 09:42 AM
IsEmpty vs RecordCount jprenou nexusdb.public.support 2 9th November 2010 09:22 AM
Can I use SQL to create new range, or change exiting range of numbers Peter Sanders nexusdb.public.support.sql 8 20th April 2006 06:12 PM
isempty set eof to true ? Roberto Nicchi nexusdb.public.support 2 6th November 2003 06:30 AM


All times are GMT +11. The time now is 01:33 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.