BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Indexing

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Bartek
Guest





PostPosted: Wed Apr 06, 2005 1:35 pm    Post subject: Indexing Reply with 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

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





PostPosted: Wed Apr 06, 2005 4:24 pm    Post subject: Re: Indexing Reply with quote



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





PostPosted: Thu Apr 07, 2005 4:44 pm    Post subject: Re: Indexing Reply with quote



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





PostPosted: Thu Apr 07, 2005 4:59 pm    Post subject: Re: Indexing Reply with 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
Rick Carter
Guest





PostPosted: Thu Apr 07, 2005 5:09 pm    Post subject: Re: Indexing Reply with quote

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





PostPosted: Thu Apr 07, 2005 5:41 pm    Post subject: Re: Indexing Reply with quote

Quote:
The trick is what syntax to use for this.

It looks like this would be supported for the BDE API call dbiAddIndex.
http://info.borland.com/devsupport/bde/bdeapiex/dbiaddindex.html

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





PostPosted: Thu Apr 07, 2005 7:27 pm    Post subject: Re: Indexing Reply with quote

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





PostPosted: Thu Apr 07, 2005 7:56 pm    Post subject: Re: Indexing Reply with quote

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





PostPosted: Thu Apr 07, 2005 8:09 pm    Post subject: Re: Indexing Reply with quote

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





PostPosted: Thu Apr 07, 2005 8:58 pm    Post subject: Re: Indexing Reply with quote

:-)

That works perfect thanks a lot, that was exactly what I needed.

Bartek


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.