 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bartek Guest
|
Posted: Wed Apr 06, 2005 1:35 pm Post subject: Indexing |
|
|
Hi,
I have one table and i would like to sort this table in this way
Field: 'City' should be sorted in "normal way", and the and the field
'number' in descending order
for example after sorting my table i would like the data to be look like
this:
'city' 'number'
berlin 80
berlin 45
london 45
london 23
london 12
warsaw 65
warsaw 34
warsaw 23
warsaw 12
How can I do this?, what should i add to this code
with IndexDefs do begin
Clear;
Update;
AddIndex('', 'ID', [ixPrimary]);
AddIndex('ind', 'CITY;NUMBER', []);
end;
I'm using Delphi 4 and Paradox Table
thanks in advance
Bartek
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Wed Apr 06, 2005 4:24 pm Post subject: Re: Indexing |
|
|
Bartek wrote:
| Quote: | Hi,
I have one table and i would like to sort this table in this way
Field: 'City' should be sorted in "normal way", and the and the field
'number' in descending order
How can I do this?, what should i add to this code
with IndexDefs do begin
Clear;
Update;
AddIndex('', 'ID', [ixPrimary]);
AddIndex('ind', 'CITY;NUMBER', []);
end;
|
As far as I know, in Paradox an index is either *all* ascending or
descending, there cannot be different directions for different columns in
the same index. Most SQL databases, like Interbase, support this just fine.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"Democracy, without the guarantee of liberty, is merely a method of
selecting tyrants." - Alan Nitikman
|
|
| Back to top |
|
 |
Bartek Guest
|
Posted: Thu Apr 07, 2005 4:44 pm Post subject: Re: Indexing |
|
|
Hi,
thx for your help,
Anyway I noticed some problem, I would like to set this index as default
so i choose:
IndexName:='ind';
but then I got an error "Index doesn't exists'
why is that is there another way to set this index as default?
| Quote: | with IndexDefs do begin
Clear;
Update;
AddIndex('', 'ID', [ixPrimary]);
with AddIndexDef do Begin
name := 'ind';
Fields := 'CITY;NUMBER');
DescFields := 'Number';
Options := [];
end;
end;
--
Brian Bushay (TeamB)
[email]Bbushay (AT) NMPLS (DOT) com[/email]
|
|
|
| Back to top |
|
 |
Bartek Guest
|
Posted: Thu Apr 07, 2005 4:59 pm Post subject: Re: Indexing |
|
|
Could u show this part of your code where you use addindex method with one
filed ascending and other descending?
thx a lot
Bartek
|
|
| Back to top |
|
 |
Rick Carter Guest
|
Posted: Thu Apr 07, 2005 5:09 pm Post subject: Re: Indexing |
|
|
| Quote: | As far as I know, in Paradox an index is either *all* ascending or
descending, there cannot be different directions for different columns
in
the same index.
|
Apparently this is now supported for Paradox 7 tables. As an experiment,
I used Paradox 9 (since it didn't seem to be supported in Database
Desktop) to interactively create a new index on Orders.db ordered by
CustNo ascending, then by OrderNo Descending.
The trick is what syntax to use for this. Sorry, I mostly just use
TTable.AddIndex when I'm creating indexes in code.
Rick Carter
[email]carterrk (AT) despammed (DOT) com[/email]
Chair, Delphi/Paradox SIG, Cincinnati PC Users Group
--- posted by geoForum on http://delphi.newswhat.com
|
|
| Back to top |
|
 |
Rick Carter Guest
|
|
| Back to top |
|
 |
Rick Carter Guest
|
Posted: Thu Apr 07, 2005 7:27 pm Post subject: Re: Indexing |
|
|
| Quote: | Could u show this part of your code where you use addindex method with
one
filed ascending and other descending?
|
I haven't needed to have one field ascending and another descending, and
AFAIK it looks like that isn't supported by TTable.AddIndex, which is why
I gave the link pointing to the dbiAddIndex example. If you need to
create the index at runtime, that may be what you need to use.
Rick Carter
[email]carterrk (AT) despammed (DOT) com[/email]
Chair, Delphi/Paradox SIG, Cincinnati PC Users Group
--- posted by geoForum on http://delphi.newswhat.com
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Thu Apr 07, 2005 7:56 pm Post subject: Re: Indexing |
|
|
See Bian Bushay's reply in this thread for an example.
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
Bartek wrote:
| Quote: | Could u show this part of your code where you use addindex method
with one filed ascending and other descending?
thx a lot
Bartek
|
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Thu Apr 07, 2005 8:09 pm Post subject: Re: Indexing |
|
|
Try the following code. I do not think the index actually got created.
Brian's code just adds the IndexDef.
AddIndex('ind','CITY;NUMBER',[],'NUMBER');
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
|
|
| Back to top |
|
 |
Bartek Guest
|
Posted: Thu Apr 07, 2005 8:58 pm Post subject: Re: Indexing |
|
|
:-)
That works perfect thanks a lot, that was exactly what I needed.
Bartek
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|