Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004

    Post Unanswered: FOXPRO - select records to new database

    I have a point database [87-042.dbf] with X,Y coordinates and names, which looks like:

    X Y Name
    655432 4762315 87-042-1
    655411 4762245 87-042-1
    655332 4762363 87-042-1
    655431 4762347 87-042-3
    655562 4762445 87-042-3
    655642 4762335 87-042-3

    From this example, I want to create 2 new databases, using partly the name of the original database, and partly the name of the points, eg.:




    where in the 1st new database, only the records named 87-042-1 would be included, and in the 2nd database, only the records named 87-042-3 would be included. It brings to mind the SELECT DISTINCT command to select out all the unique names, i.e., 87-042-1, 87-042-3, but I don't know how to incorporate this into a subsequent query which would export all points of that name.



  2. #2
    Join Date
    Dec 2003
    Well, you're on the right track. The thing about DISTINCT though is that it will only get one record for each disctinct item in a particular field. So what you would end up with is a bunch of tables named properly, with only one record each. You would use the distinct clause to gather up the names and use a work table like I have shown in the code.

    Try this out. Save it as say, 'GROUPS.PRG'. The issue a DO GROUPS command from the command line:
    *...  GROUPS.PRG ...
    STORE "87-042"  TO cOrigTable
    USE (cOrigTable) ALIAS original
    SELECT DISTINCT name from original ;
       INTO CURSOR work
    SELECT work
       STORE cOrigTable + '_' + TO cOutTable  
       SELECT * FROM original ;
          WHERE =;
          INTO TABLE (cOutTable)
       SELECT work      
    Now if you want to run this thing using a bunch of different tables, just change the line
    STORE "87-042"  TO cOrigTable
    PARAMETERS cOrigTable
    and you can then pass it the name of the table you want to use like this:
    DO GROUPS WITH "87-042".

    Even more Fox stuff at

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts