Board index » delphi » Switching Indexes

Switching Indexes

Hi, I have an app which uses filtering for different users on a network,
I also have a findkey routine which switches to a secondary index then
back on completion of the routine. I find when I do this I then lose the
filtering that has been set up.

Q. Can I use secondary indexes without switching as in clipper or how
else can I avoid losing the filtering?

Any help appreciated

 

Re:Switching Indexes


Quote
Eric Gunstone <gunst...@deakin.edu.au> wrote:
>Hi, I have an app which uses filtering for different users on a network,
>I also have a findkey routine which switches to a secondary index then
>back on completion of the routine. I find when I do this I then lose the
>filtering that has been set up.

>Q. Can I use secondary indexes without switching as in clipper or how
>else can I avoid losing the filtering?

Unfortunately Delphi's (Version 1.0x) filtering and searching capabilities such
as SetRange() and FindKey() are limited to the active index.
In Delphi 2 there is a Filter property that does the job (but haven't tried it
yet ...)
So there are two possible "workarounds" that I have been working with so far:

1. Use TQuery with the appropriate SQL-Statement if all you want to display is
   a certain view on the data you have (I know that this is slow ... but it
   works !)
2. Depending on the structure of your tables you might combine two or more
   columns of your table to an index and filter them using SetRange().

   example :

   suppose you have a Table named Table1 with a column
     CUSTNR representing the customer-number
   and
     CUSTORDER representing the number of orders a certain customer placed

   with Table1 do
     begin
       { opening table in exclusive mode for building index }
       Close;
       Exclusive := TRUE;
       Open;
       AddIndex( 'NEWIDX', 'CUSTNR;CUSTORDER', [] );
       { reopening table in shared mode for networking environments }
       Close;
       Exclusive := FALSE;
       Open;
       { set appropriate index }
       IndexName := 'NEWIDX';
       { display all customers with numbers between 1000 and 2000 who have
         placed a single order so far ... }
       SetRange( [ '1000', 1 ], [ '2000', 1 ] )
     end; { of WITH }

  you obviously should use lots of TRY-EXCEPT-END's in here ... ;->

  Hope that helps ... (if it does not : email to cwet...@htw.uni-sb.de)

    Christian

--
-----------------------------------------------
 Christian Wettig, student of computer science
           HTW, Saarbruecken, Germany        
---[ send email to : cwet...@htw.uni-sb.de ]---

Re:Switching Indexes


Eric,

How about having a separate TTable controls for your filter and findkey?
I sometimes use multiple objects accessing the same table in different
ways.
Works well for me.

Peter

Quote
> Eric Gunstone <gunst...@deakin.edu.au> wrote in article

<31BE4EC6.5...@deakin.edu.au>...
Quote
> Hi, I have an app which uses filtering for different users on a network,
> I also have a findkey routine which switches to a secondary index then
> back on completion of the routine. I find when I do this I then lose the
> filtering that has been set up.

> Q. Can I use secondary indexes without switching as in clipper or how
> else can I avoid losing the filtering?

> Any help appreciated

Re:Switching Indexes


In article <01bb580a.113dca40$1d8f06cb@none>, "Peter Szymiczek"

Quote
<szymi...@bmw.com.au> writes:
>Eric,

>How about having a separate TTable controls for your filter and findkey?
>I sometimes use multiple objects accessing the same table in different
>ways.
>Works well for me.

>Peter

I would go along with this idea.  I often use multiple TTable components
to achieve the sort of thing Eric refers to below.  The prog
size/performance overheads appear to be small.

Quote
>> Eric Gunstone <gunst...@deakin.edu.au> wrote in article
><31BE4EC6.5...@deakin.edu.au>...
>> Hi, I have an app which uses filtering for different users on a
network,

>> I also have a findkey routine which switches to a secondary index then
>> back on completion of the routine. I find when I do this I then lose
the

>> filtering that has been set up.

>> Q. Can I use secondary indexes without switching as in clipper or how
>> else can I avoid losing the filtering?

>> Any help appreciated

--------------------------------------------------------------------------
--
 Brian Stone, Peterborough, UK (ston...@aol.com)
--------------------------------------------------------------------------
--

Other Threads