Board index » cppbuilder » How to use to indexes

How to use to indexes


2005-07-14 04:04:12 AM
cppbuilder99
Hi,
I have a TTable with one field as Date and one field as TTime
and I set both fields as Secondary Indexes.
I need to list the table so it shows the latest date and early time:
For example:
//I need to get this
July 06, 2005 09:00AM // instead of 04:00PM
July 06, 2005 04:00PM // instead 09:00AM
June 27, 2005 09:00AM
June 27, 2005 10:00AM
etc.
I currently call the Date index to list by Date but the Time I guess shows the opposite, as follow
//This is what I get - no time deccendent listing
July 06, 2005 04:00PM
July 06, 2005 09:00AM
June 27, 2005 09:00AM
June 27, 2005 10:00AM
Am I missing something?
thanks
Freddy
 
 

Re:How to use to indexes

Hi,
I do not work with BDE/TTable a long time so I do not
know exactly how to solve your problem without working
with TQuery which definitely *can* sort your dataset by
'Date' and then by 'Time'.
But if I were you I will switch immediatelly to ADO set of
components (TADOTable, TADOQuery, ...) which are
*much more* flexible & featured for work. Switching to ADO
is a question of few hours...
For example, TADOTable has 'Sort' property, which you
can use this way:
// note: ASC ascending, DESC desceding
ADOTable1->Sort = "Date ASC, Time ASC";
or just:
ADOTable1->Sort = "Date, Time";
Further, in such cases I prefer using TADOQuery, which
is much more flexible for work and also return live datasets:
SELECT *
FROM Table
WHERE SomeClauseIfAny
ORDER BY Date, Time
--
Best regards,
Vladimir Stefanovic
 

Re:How to use to indexes

Freddy Mas wrote:
Quote
Hi,
I have a TTable with one field as Date and one field as TTime
and I set both fields as Secondary Indexes.

I need to list the table so it shows the latest date and early time:
For example:
//I need to get this
July 06, 2005 09:00AM // instead of 04:00PM
July 06, 2005 04:00PM // instead 09:00AM
June 27, 2005 09:00AM
June 27, 2005 10:00AM
etc.

I currently call the Date index to list by Date but the Time I guess shows the opposite, as follow
//This is what I get - no time deccendent listing
July 06, 2005 04:00PM
July 06, 2005 09:00AM
June 27, 2005 09:00AM
June 27, 2005 10:00AM

Am I missing something?
thanks
Freddy

You need to have a primary key field of type auto increment and define a
secondary index that uses the date and time field. Selecting the date/
time index will make the records appear in the order that you desire.
HTH,
Danzer
 

{smallsort}

Re:How to use to indexes

Thanks Danzer, your suggestion helped indeed.
I created a secondary Index with Date and Time and I got the table sorted based on ascending values.
Do you if I can make Time ascending and Date Descending or vise-vera.
thanks again
Freddy
Danzer < XXXX@XXXXX.COM >wrote:
Quote
Freddy Mas wrote:
>Hi,
>I have a TTable with one field as Date and one field as TTime
>and I set both fields as Secondary Indexes.
>
>I need to list the table so it shows the latest date and early time:
>For example:
>//I need to get this
>July 06, 2005 09:00AM // instead of 04:00PM
>July 06, 2005 04:00PM // instead 09:00AM
>June 27, 2005 09:00AM
>June 27, 2005 10:00AM
>etc.
>
>I currently call the Date index to list by Date but the Time I guess shows the opposite, as follow
>//This is what I get - no time deccendent listing
>July 06, 2005 04:00PM
>July 06, 2005 09:00AM
>June 27, 2005 09:00AM
>June 27, 2005 10:00AM
>
>Am I missing something?
>thanks
>Freddy
>

You need to have a primary key field of type auto increment and define a
secondary index that uses the date and time field. Selecting the date/
time index will make the records appear in the order that you desire.

HTH,
Danzer
 

Re:How to use to indexes

Freddy Mas wrote:
Quote
Thanks Danzer, your suggestion helped indeed.

I created a secondary Index with Date and Time and I got the table sorted based on ascending values.

Do you [know] if I can make Time ascending and Date Descending or vise-vera.

thanks again
Freddy

One of the enumerated values for TIndexOption is ixDescending; this is
passed as an argument to TTable->AddIndex. It appears you can have
descending indexes even though I have not tried it.
Danzer