Page 1 of 1

<TOraQuery>.RecNo - a bit odd indexing?...

Posted: Tue 08 Mar 2016 12:32
by pcz
Hello

It looks like indexing records by <TOraQuery>.RecNo is not 0 based - valid values are in range [1..<TOraQuery>.RecordCount]
Is it intended behaviour?
Why?...

[ODAC 9.6.22]

Regards
P.C.


PS. Example:

Code: Select all

for I := 0 to OraQuery1.RecordCount - 1 do   // loops for all but one record
begin
  OraQuery1.RecNo := i;
  if OraQuery1.RecNo <> i then   // happens for i = 0
    ShowMessage('Problem?');
end;

Re: <TOraQuery>.RecNo - a bit odd indexing?...

Posted: Thu 10 Mar 2016 08:40
by AlexP
Hello,

This is correct behavior, since record count starts from 1, not from 0, in contrast to field count.

Re: <TOraQuery>.RecNo - a bit odd indexing?...

Posted: Tue 05 Apr 2016 11:10
by pcz
AlexP wrote:Hello,
This is correct behavior, since record count starts from 1, not from 0, in contrast to field count.
I didn't know :roll:

:idea:
It would be nice to mention about this somewhere in help files because not all TDataSet descendants have 1 based RecNo

Thank You for confirmation!

Re: <TOraQuery>.RecNo - a bit odd indexing?...

Posted: Mon 11 Apr 2016 09:21
by AlexP
In the TDataSet basic class, the RecNo property always equals -1. In standard descendants (ADO, BDE, FireDAC), the value of this property starts from 1.
We made behavior of our components similar to standard.

Re: <TOraQuery>.RecNo - a bit odd indexing?...

Posted: Tue 12 Apr 2016 08:29
by pcz
AlexP wrote:In the TDataSet basic class, the RecNo property always equals -1. In standard descendants (ADO, BDE, FireDAC), the value of this property starts from 1.
We made behavior of our components similar to standard.
I totally understand and I think that it's not so bad idea :)

But if somebody new is looking documentation he finds:
TMemDataSet = class(TDataSet);
Remarks
TMemDataSet derives from the TDataSet database-engine independent set of properties, events, and methods for working with data and introduces additional techniques to store and manipulate data in memory.
and then after he navigates to "Data.DB.TDataSet.RecNo"...
As implemented in TDataSet, the value of RecNo is always -1. Ordinarily an application does not access RecNo at the TDataSet level. Instead a re-implemented RecNo property in a descendant class such as TTable TClientDataSet is accessed. RecNo provides a fallback property for derived datasets that do not support record numbers.
I think that maybe TMemDataSet "Remarks" section could be good place to mention about that

Re: <TOraQuery>.RecNo - a bit odd indexing?...

Posted: Tue 12 Apr 2016 08:46
by AlexP
We will add description of this property to the help shortly.