I need to reposition the cursor after apply the filter, to the old record. The problem is if the record are not in the result set, it appear in the result set after I set a bookmark.

mBookmark := Bookmark;

Filter := 'CONTAINS(FieldName, ''Question'')';
Filtered := True;

try
   Bookmark := mBookmark;
except
   First;
end;

To resolve this problem, I set the AdsTableOptions.AdsFilterOptions to RESPECT_WHEN_COUNTING before Bookmark := mBookmark. But, if I set this, the initialising bookmark are very slow on a big table, more than 900000 records.

Is it that there is an alternative way to set a bookmark and the bookmark return an error.

asked 29 Sep '14, 08:09

Marius%20Cere's gravatar image

Marius Cere
161182025
accept rate: 0%

Maybe you can save the Integer value of the Primary key field into a variable and then Locate for it instead of using bookmarks.

(29 Sep '14, 13:26) Marc

It's a solution, but is not possible to introduce this in our software.

(30 Sep '14, 05:45) Marius Cere

Yes, it's the way I will use to correct the problem.

Thanks Edgar!!

(30 Sep '14, 07:52) Marius Cere

I unfortunately do not have Delphi to test, but have you tried playing with the sequenced property or getting the record number and then going back to the record? Not sure if it will be faster or not.

link

answered 30 Sep '14, 07:37

Edgar%20Sherman's gravatar image

Edgar Sherman
5.4k13185
accept rate: 25%

The problem is, if I have an filter with CONTAINS, when I set a Recno or a bookmark, the record appear when it's not included in result set.

To resolved this, I set the AdsTableOptions.AdsFilterOptions to RESPECT_WHEN_COUNTING. But with this, the setting a record or a bookmark is very, very slow on a big database, over 900000 records in a table.

var
   MyQuery: TAdsQuery;
   mRecno: Integer;
   mRecnoAfterFiltered: Integer;

begin

   ...

   mRecno := MyQuery.Recno;

   MyQuery.Filter := 'CONTAINS(FieldName, ''Question'')';
   MyQuery.Filtered := True;

   mRecnoAfterFiltered := MyQuery.Recno;

   try
      MyQuery.Recno := mRecno;

   except
      if ( mRecnoAfterFiltered <> -1 ) then
         MyQuery.Recno := mRecnoAfterFiltered
      else
         MyQuery.First;
   end;
end;

With this code, when I Set the recno in Try section, never error occurs because an CONTAINS include in the filter.

To resolved this problem, I use this code :

var
   MyQuery: TAdsQuery;
   mRecno: Integer;
   mRecnoAfterFiltered: Integer;

begin

   ...

   mRecno := MyQuery.Recno;

   MyQuery.Filter := 'CONTAINS(FieldName, ''Question'')';
   MyQuery.Filtered := True;

   mRecnoAfterFiltered := MyQuery.Recno;

   try
      MyQuery.AdsTableOptions.AdsFilterOptions := RESPECT_WHEN_COUNTING;

      MyQuery.Recno := mRecno;

      MyQuery.AdsTableOptions.AdsFilterOptions := IGNORE_WHEN_COUNTING;

   except
      if ( mRecnoAfterFiltered <> -1 ) then
         MyQuery.Recno := mRecnoAfterFiltered
      else
         MyQuery.First;
   end;
end;

But, with this code, when I set a recno is very very slow. My table contains over 900000 records.

link

answered 01 Oct '14, 08:43

Marius%20Cere's gravatar image

Marius Cere
161182025
accept rate: 0%

Your answer to the original question.
If responding to a request for additional information, please edit the question or use the comment functionality.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×325
×271
×93

Asked: 29 Sep '14, 08:09

Seen: 2,462 times

Last updated: 01 Oct '14, 08:43

Advantage Developer Zone Contact Us Privacy Policy Copyright Info


Powered by Advantage Database Server and OSQA
Disclaimer: Opinions expressed here are those of the poster and do not necessarily reflect the views of the company.