View Full Version : delete a range of records
| Is there a way to delete a range of records from a table by using the recno values? |
probably
you posted in the "Other PC Databases" forum, but neglected to mention which one you're using
How would you normally go about deleting a record?
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.
Can you define what you mean by "record numbers" please?
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.
Have you considered the GO (http://msdn2.microsoft.com/en-us/library/aa977827(VS.71).aspx) command?
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.
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
DELETE FROM people
WHERE person_id BETWEEN 20 AND 30
the dbase command is:- delete all for recno() > xx .and. recno() < xxx
vBulletin v3.5.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.