Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index problem on cursor

Status
Not open for further replies.

fluppeke

Programmer
Aug 30, 2006
38
0
0
BE
Dear Experts,

For You it might be a very simple answer on the following question:

In the load of the form I make a cursor file:
Code:
create cursor tmpclient;
       (  client      C(8),;
          order       N(10,0),;
          orderdate   D(8),;
           ............
          end         C(1))
index on client [b]ascending[/b] tag client additive

This works
Why does the following thing doesn't

index on client [b]ascending[/b] + str(order,10,0) [b]descending[/b] tag client additive

wfg,

Filip Merlier
 
Filip,

Sorry, but you can't do that.

You are trying to concatenate ascending with str(order,10,0). That doesn't make sense.

You might try something like this:

INDEX ON Client + STR(999999999 - Order, 10, 0) ASCENDING ...

(where 99999999 is the highest order no. you are likely to have).

But be warned that this will be horribly inefficient if the table is large.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You cannot mix ascending and descending keys in the same index key. An index is not a 'sort', so the ascending / descending applies to the whole key, not to individual elements.

If you want the Client ascending and and the Order number descending use a tag like this:

Code:
client + str( 0 - order, 10, 0 )



----
Andy Kramek
Visual FoxPro MVP
 
...And once the index is created in ascending order, you can always set the order to descending when or if you need it:

Code:
USE MyTable
SET ORDER TO MyTag [COLOR=red]DESCENDING[/color]


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top