PDA

View Full Version : delete a range of records


wehrle
03-09-08, 23:51
Is there a way to delete a range of records from a table by using the recno values?

r937
03-10-08, 06:09
probably

you posted in the "Other PC Databases" forum, but neglected to mention which one you're using

wehrle
03-10-08, 08:35
Visual FoxPro

georgev
03-10-08, 09:35
How would you normally go about deleting a record?

wehrle
03-10-08, 10:06
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.

georgev
03-10-08, 10:09
Can you define what you mean by "record numbers" please?

wehrle
03-10-08, 10:15
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.

georgev
03-10-08, 10:27
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

Peto4122
03-16-08, 19:41
the dbase command is:- delete all for recno() > xx .and. recno() < xxx