Solved

Order By in Visual Fox Pro  6.0

Posted on 2011-03-09
3
610 Views
Last Modified: 2012-05-11
Hello Experts,

I have code like this:

Code Snippet:
IF USED("Results")
      SELECT Results
ELSE
      SELECT 0
      USE Results
ENDIF
CURSORSETPROP("buffering",3)


 I need the Results table(or DBF) file to be Order by Datetime, since the table contains the datetime field.

How can I do that in Fox Pro 6.0
0
Comment
Question by:ASPDEV
3 Comments
 
LVL 1

Expert Comment

by:hiraben
Comment Utility
Any of these:

1) You can use: select * from results order by datetime --> this won't be updatable (changes won't be saved)
2) you can use: sort to results_ordered on datetime
3) you can create a local view on the results table and set the order to datetime. This requires creating a database, but it is the best solution because it is updateable
0
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
Comment Utility
The easiest thing you can do is INDEX.

SELECT Results
INDEX ON datetimeField TO (SYS(2023)+"\TmpIndex") COMPACT

and from now the table is ordered as you need. This kind of index is a bit temporary and it is not updated by other instances which use same DBF. If you need something more "permanent" and updated from all users then you should add index tag into the structural index file:

USE Results EXCLUSIVE
INDEX ON datetimeField TAG SomeName
USE

And from now when you need the table ordered by datetimeField simply issue:

SET ORDER TO TAG SomeName

The tag name must be up to 10 characters. You may also decide about the ascending or descending order.
0
 

Author Closing Comment

by:ASPDEV
Comment Utility
Excellent!

Thanks,
ASPDEV
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 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

13 Experts available now in Live!

Get 1:1 Help Now