|
Log in |
FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]() 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
|
|||
|
|||
![]() 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
|
|||
|
|||
![]() 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
|
|||
|
|||
![]() 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
|
|||
|
|||
![]() 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 | |
|
|
![]() |
||||
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 |