Solved

SetRange() on multifield indexes.

Posted on 1998-06-30
4
549 Views
Last Modified: 2010-05-18
Hello there,

I've created index for few fields. I'm willing to apple range for my table, and seems I can not do that.
For example I've two fields: Symbol and Number. I've created index for these fields. TotalIndex.
Now, I'm trying something like this:

  with Table1 do
  begin
    IndexName := 'TotalIndex';
    SetRange(['a', 1],  ['m', 10]);
    ApplyRange;
  end;

I'm expecting to see all records with Symbol's value between 'a' and 'm' and
and Number's value between 1 and 10 but nothing happens. At all.
When I create separate indexes for each co;umn and write for example:

  with table1 do
  begin
    IndexName := 'NumIndex';
    SetRangeStart;
    FieldByName('Number').AsInteger := 1;
    SetRangeEnd;
    FieldByName('Number').AsInteger := 10;
    ApplyRange;
  end;

I see just what I expected to see. But I want to use one index for all fields. Possible? How?
0
Comment
Question by:_art_
4 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356648
You didn't set the range properly. This range shows symbols between 'a' and 'm' that also have numbers between 1 and 10. If you want to see both then you should use Filter instead of Range:

 with table1 do
 begin
     Filter:='SYMBOL<='+Chr(39)+'m'+Chr(39)+' AND                 SYMBOL>='+Chr(39)+'a'+Chr(39)+' OR NUMBER<=10 AND NUMBER>=1';
     Filtered:=True;
end;  

0
 

Author Comment

by:_art_
ID: 1356649
ronit,

Exactly what I need! I wanna see  records whose symbols between 'a' and 'm' and from them those where numbers between 1 and 10. Not both cases separate..
I know filters still would be the right suggestion but at some reasons I'd prefer not to use them.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1356650
Hi _art_,

Why don't you want to use Filters?

Well, maybe this is possible :

 1. Take two tables, one master other detail.
 2. Filter the master table with a to m
 3. Filter the slave with 1 to 10

Never tried it, don't even know if it will work, but you can try it.

Regards, ZiF.
0
 
LVL 3

Accepted Solution

by:
vladika earned 100 total points
ID: 1356651
I think with SetRange it's impossible.
Why?
Let Table have such date
SYMBOL      NUMBER
----------------------------------
a                     -1
a                      1
b                     -5
b                    10
m                    -1
m                   11
z                     0

I ordered it according to index.

SetRange(['a', 1],  ['m', 10]) set TWO BOUNDARIES (and ONE range) in ordered table.
First boundary between ('a',-1) and ('a',1).
Second boundary between ('m',-1') and ('m',11)
So you can see ('b',-5), ('m',-1) etc

You want set many ranges. It's impossible with SetRange

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now