Unidirection=true makes First not at first

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
applespring
Posts: 22
Joined: Tue 15 May 2012 14:01

Unidirection=true makes First not at first

Post by applespring » Tue 15 May 2012 14:12

Hello

ODAC v8.1.6+Delphi2006+WinXP

I found for TOraQuery, if Unidirection is set to true, then a call to First will not return to the real First record.

To reproduce this:

1. Make a TOraQuery to open, say 2100 records.
2. Close this TOraQuery
3. Set Unidirection=True; FetchAll:=False; FetchRows:=1000;
4. Open this TOraQuery
5. Call a while-loop to the end of this TOraQuery
6. Checking that TOraQuery.RecNo, it is the last record
7. Call TOraQuery.First
8. Checking thaat TOraQuery.RecNo, you can see that it is only 1000 record backwards, not at the real beginning of the dataset.

Please kindly check it.

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

Re: Unidirection=true makes First not at first

Post by AlexP » Tue 15 May 2012 16:06

Hello,

This is a correct behaviour, since the Unidirection mode means using of a unidirectional DataSet, i.e. there are only those records stored in DataSet that were retrieved in the last fetch operation (the records number equals the FetchRows value), and you can move cursor up only in limits of the current records. All records read earlier are replaced by the new ones, and there is no access to them

applespring
Posts: 22
Joined: Tue 15 May 2012 14:01

Re: Unidirection=true makes First not at first

Post by applespring » Wed 16 May 2012 01:23

Hello

I think I have different opinions on this behavior.

As your document describes in Unidirectional property:

"Traditionally SQL cursors are unidirectional. They can travel only forward through a dataset. TCustomDADataset, however, permits bidirectional travelling by caching records. If an application does not need bidirectional access to the records in the result set, set UniDirectional to True. "

This implies that when we set Unidirectional to true, we can only travel forward by a call to Next without need to caching records which have already been read.

As derived from TDataSet, the same behavior such as First, Next, EOF should be kept as the same as before, otherwise, this will cause very headache problem.

In the real case, we are extending one of our data-mining application interface to support Oracle by using ODAC, and this interface all the database objects will be passed as a TDataSet, and inside it, it will be First, Next, EOF called.

And this different behavior of First have trapped us greatly because we never expect so.

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

Re: Unidirection=true makes First not at first

Post by AlexP » Wed 16 May 2012 13:17

Hello,

In BDE the UniDirection option works only in case of using native Oracle driver. If you are using ODBC driver, the cursor will be bidirectional independently on this option value. When attempting to use the First, Prior, etc. methods (backward move), while the UniDirection option is enabled, and the native driver is used, you will get an error message. We have fixed this behaviour - when attempting to use these methods in our DataSets, you can move through the current DataSet with no errors.

applespring
Posts: 22
Joined: Tue 15 May 2012 14:01

Re: Unidirection=true makes First not at first

Post by applespring » Thu 17 May 2012 07:54

Hello

I am using ODBC with Direct mode.

So it means a call to First to TOraQuery in case Uniditional=true will not move to the real beginning of the database but only the beginning of the "fetched" result?

Am I right?

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

Re: Unidirection=true makes First not at first

Post by AlexP » Thu 17 May 2012 11:07

Hello,

Yes, you are right. Our components behave exactly in such way in the Unidirectional mode - moving upward is possible only in the limits of the current fetched data.

Post Reply