Solved

SetRange() on multifield indexes.

Posted on 1998-06-30
4
579 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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