Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2005
    Posts
    103

    Unanswered: delete a range of records

    Is there a way to delete a range of records from a table by using the recno values?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    probably

    you posted in the "Other PC Databases" forum, but neglected to mention which one you're using
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2005
    Posts
    103
    Visual FoxPro

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    How would you normally go about deleting a record?
    George
    Home | Blog

  5. #5
    Join Date
    Jul 2005
    Posts
    103
    delete from sometable where somefield = somevalue

    The problem is that I do not have any magic values to check in any normal fields. I only know a range of records by their record numbers.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Can you define what you mean by "record numbers" please?
    George
    Home | Blog

  7. #7
    Join Date
    Jul 2005
    Posts
    103
    The record number for record one is 1.
    The record number for record two is 2.
    I believe those numbers can be returned with the recno() function, but I am not sure.

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Have you considered the GO command?
    Code:
    GO [RECORD] nRecordNumber [IN nWorkArea | IN cTableAlias]
    However; you do realise that RecNo() should only be used when you specify the ORDER or the open table?

    E.g.
    Code:
    USE people
    SET ORDER TO surname
    However, using FP code is not the best method for this. You are going to want to look at using SQL as per your example before.
    Perhaps you want to delete records where the primary key value is between 20 and 30 inclusive
    Code:
    DELETE FROM people
    WHERE   person_id BETWEEN 20 AND 30
    George
    Home | Blog

  9. #9
    Join Date
    Mar 2008
    Posts
    4

    Delete records

    the dbase command is:- delete all for recno() > xx .and. recno() < xxx

Posting Permissions

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