Solved

SetRange() on multifield indexes.

Posted on 1998-06-30
4
563 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 119
problem when i try to pack my dll file with upx 9 76
delphi exception 7 64
drawing animated level bar based on numbers 3 96
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

815 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

12 Experts available now in Live!

Get 1:1 Help Now