Additional
AnyDAC
SimpleIAX
Forums
Welcome, Guest
Please Login or Register to post messages. Lost Password?
[5.0.5 build 2073] fast read-only query does not return results ?
(1 viewing) 1 Guest
Go to bottom
TOPIC: [5.0.5 build 2073] fast read-only query does not return results ?
#21971
OscarReynhout
Fresh Boarder
Posts: 3
graphgraph
Karma: 0
User Offline Click here to see the profile of this user
[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/18 06:25 (8 Months ago)
We've got various situations where we need to access large lists of data from our database.

The FAQ states that for fast forward-only read-only access I would have to use these options :

CursorKind = ckDefault or ckForwardOnly
Mode = fmOnDemand
RowsetSize = 1000
Unidirectional = True
optionally exclude fiMeta from Items, if you does not need to edit dataset.

However I noticed that in Delphi 7 / MS SQL 2005 some queries were returning no results.

Example of this query :
Code:


  FItems := TADQuery.Create(Nil);
  // TO DO
  //FItems.LockType := ltPessimistic;
  FItems.Connection := TheDatabaseConnection.Anydac;
//  FItems.Transaction:= FReadOnlyTransaction;
  FItems.FetchOptions.Unidirectional := True;
  FItems.FetchOptions.CursorKind     := ckForwardOnly;
  FItems.FetchOptions.Items          := FItems.FetchOptions.Items - [fiMeta];

  FItems.SQL.Add('SELECT OEE_TB.[TbnCode]');
  FItems.SQL.Add('  , OEE_TBN.[TbnNaam]');
  FItems.SQL.Add(', ISNULL((SELECT MessageText FROM MasterDataTranslations WHERE TextId=(''OEE_TBN_TBNName_'' + CONVERT(NVARCHAR(255), OEE_TBN.[TbnCode])) AND Id = ' + IntToStr(Usr.UserLanguage) + '), OEE_TBN.[TbnNaam]) AS TbnNaamTranslated ');
  FItems.SQL.Add('FROM OEE_TB WITH(NOLOCK)');
  FItems.SQL.Add('INNER JOIN OEE_TBN WITH(NOLOCK) ON OEE_TBN.[TbnCode] = OEE_TB.[TbnCode]');
  FItems.SQL.Add('WHERE (OEE_TB.DevCode = :pDevCode)');
  FItems.SQL.Add('ORDER BY OEE_TB.[Volgorde], OEE_TBN.[TbnNaam], OEE_TBN.[Volgorde]');
    FItems.ParamByName('pDevCode').Value := FCycleInfo.DevCode //
  FItems.Prepared := True;

    FItems.Open;
    FItems.FetchAll;
//  ... checking FItems.RecordCount reveals 0 records
// executing this exact query in Management Studio does result in data !



Is there a problem with this example or is this a known bug in this version of Anydac ?
Logged Logged
Last Edit: 2012/09/18 06:26 By OscarReynhout.
The administrator has disabled public write access.
#21972
Support
Moderator
Posts: 5635
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/18 06:57 (8 Months ago)
Hello

Try to exclude FetchAll call, as it is not compatible with Unidirectional = True.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
#21973
OscarReynhout
Fresh Boarder
Posts: 3
graphgraph
Karma: 0
User Offline Click here to see the profile of this user
Re:[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/18 07:14 (8 Months ago)
Do newer versions give a warning or an error if this combination is used ?
Because some queries did return results locating the issue was a real problem for us.

I will look into replacing 'FetchAll'
Logged Logged
The administrator has disabled public write access.
#21974
Support
Moderator
Posts: 5635
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/18 07:39 (8 Months ago)
No, it does not give an error.

But you can use a conditional breakpoint at beginning of TADDataSet.InternalFetchRows method, with a condition "FetchOptions.Unidirectional and AAll". Or put an ASSERT.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
#21984
OscarReynhout
Fresh Boarder
Posts: 3
graphgraph
Karma: 0
User Offline Click here to see the profile of this user
Re:[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/19 03:45 (8 Months ago)
I'd prefer not to modify the Anydac sources, because I fear it will cause problems once we upgrade to v6 or later.
Logged Logged
The administrator has disabled public write access.
#21985
Support
Moderator
Posts: 5635
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:[5.0.5 build 2073] fast read-only query does not return results ? 2012/09/19 04:17 (8 Months ago)
Conditional breakpoint - you does not need to modify sources.
Assert - this is temporary solution. Later you can safely overwrite change.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
Go to top