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!

SCAN ... ENDSCAN with sorting ?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Sample 1:
SELECT * from table order by date into cursor tmp
SCAN
insert to another cursor statement
ENDSCAN

Notice that this approach in sample 1 creating 2 cursors which is space consuming for same set of data.

I'm trying to use the SCAN....ENDSCAN. Wondering is there a way to sorting the block of data comming into the SCAN command ?


 
I'm dont think i have understood your problem - but the block of data in the example you have shown above will be sorted by date as given in the select statement.
 
PeterWoo

You need to include a filter condition(s) so that you create a single cursor without the need for SCAN...ENDSCAN

SELECT * from table order by date into cursor tmp

could be

SELECT * from table order by date WHERE country = "USA" into cursor tmp


Check out SELECT - SQL Command in the VFP Help file.
HTH

Chris [pc2]
 
HI,

If you want to index the Order of any rows in the SCAN .. ENDSCAN command use the SQL Statement with INDEX BY attribute

Am i understood your problem correctly?

Suggestions Invited...

gchandrujs [sunshine]
 
Sorry, I think I confused you all with my lengthy question. Lets make it simple.

I wish to use SCAN...ENDSCAN with sorting of date in a table. Meaning, oldest date first until most recent date.

Thanks.
 
Peter,
That's what you should be getting with your "sample 1" code. Are you seeing something different? What?

As suggested by gchandrujs, since you aren't "filtering" the records in the SQL Select, then you could just create a temporary index on the date field and SCAN while it's in use.

Rick
 
set the order on the origin table first

select table1
set order to date &&must have this index
scan for date={01/01/2002} &&or some other statement
insert into table2
endscan
 
read my last post, technically correct but may be confusing to some users.

should have been

select table1
set order to date &&must have this index
scan for date={01/01/2002} &&or some other statement
scatter memvar
insert into table2 from memvar
endscan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top