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

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

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

Post by pcz » Tue 08 Mar 2016 12:32

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;

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Thu 10 Mar 2016 08:40

Hello,

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

pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

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

Post by pcz » Tue 05 Apr 2016 11:10

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!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Mon 11 Apr 2016 09:21

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.

pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

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

Post by pcz » Tue 12 Apr 2016 08:29

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Tue 12 Apr 2016 08:46

We will add description of this property to the help shortly.

Post Reply