Solved

Order By in Visual Fox Pro  6.0

Posted on 2011-03-09
3
633 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
ID: 35088096
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
ID: 35088233
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
ID: 35088573
Excellent!

Thanks,
ASPDEV
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

810 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