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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attempting to delete records from a specific point in file

Status
Not open for further replies.

EBOUGHEY

Programmer
Joined
Aug 20, 2002
Messages
143
Location
US
Hi. I have created a field that stores a specific quantity for a job. I would like my program to take the quantity in the field, go to that record number, and copy then delete all records after that number

The below code is not working for me though. I am okay until I get to the skip next &quantity. Can someone help me out with this?

Thanks,

Elena Boughey

alter table alltrim(lower(thefile)) add column QUANTITY C(10)

CCOUNT = SPACE (50)

clear
@ 5,5 say 'Enter Quantity for job: ' get CCOUNT
READ
clear
repl all QUANTITY with ALLTRIM(CCOUNT)

SKIP next &QUANTITY
DELETE REST
COPY TO overs FOR DELETED()
pack
 
check the status of the set delete on/off

your method sounds like a little usual process. what are you excatly doing? Attitude is Everything
 
We are running 81 separate jobs. Each job has to be a certain quantity. If the quantity is higher, we have to copy the remainder to a file, delete them then pack the file.

What I am trying to do is enable us to enter the quantity, then store that quantity in a field.

Then I want the program to take me to that record number so I can delete everything after it.

Does that make sense?

 
I want the program to delete all the records after the quantity is reached.

I just want it to be as automated as possible because we are looking at 32+ hours of data time with 2 people on jobs that drop on Friday!

 
how about

select * from mytable TOP varcount into cursor/table

use this curosr/table as your work file, there would beno need to delete the rest, that table would remain the same. Attitude is Everything
 
Is there some way to use the variable CCOUNT that I created and link it to the reccount()?

 
The file I am using is the actual job file. I will be doing a lot more data work to it first.

After all the other data work is done, is there going to be a way for me to delete records that exceed the quantity I stored to a variable called CCOUNT starting at the end of the file and going backwards until the record count is reached?

The ending count has to be a .dbf file because we are presorting it in a different program.

 
did you check the set delete on/off?? Attitude is Everything
 
if set delete on/off is not it, then use your ccount to goto the record, then
do while !eof()
delete
enddo Attitude is Everything
 
Is there a quicker way to do this code? It keeps bombing on me unless I index on the "A" file:



CLEAR
clos all
SET SAFETY OFF


@ 5,5 say 'OPEN JOB NUMBER DATABASE: '
thefile = getfile('DBF')


use alltrim(lower(thefile))
alter table alltrim(lower(thefile)) add column DEALERCODE c(10)
alter table alltrim(lower(thefile)) add column BEACON c(10)
alter table alltrim(lower(thefile)) add column QUANTITY n(10)

CDEALER = SPACE (20)
CCOUNT = SPACE (10)

clear
@ 5,5 say 'Enter Quantity for job: ' get CCOUNT
@ 7,5 say 'Enter Dealer Number: ' get CDEALER
READ
clear
repl all DEALERCODE with UPPER(alltrim(CDEALER))
repl all QUANTITY with VAL(ALLTRIM(CCOUNT))
REPLACE ALL BEACON WITH '10'+BEACON1
SET SAFETY OFF
SELECT a
USE N:\INKJET\DALLASZONE\DALLAS
INDEX ON DEALERCODE TO T
SET SAFETY ON
SELECT b
@ 5,5 say 'OPEN JOB NUMBER DATABASE: '
USE ?
SET RELATION TO dealercode INTO A
APPEND FROM n:\inkjet\dallaszone\dallas FOR !EOF(1)
GO top
qty = VAL(ccount)
GO qty
SKIP 1
DELETE REST
COPY TO overs FOR DELETED()
pack
CLOSE ALL


RETURN
 
relation ships require an index.that you can build.

the code you post has went out with the bell bottom trousers. are you working with visual foxpro? if not I suggest that you ask your questions in the 2.6 forum. if you are working with visual, you need to get you some good books and do some reading.

the things that you are doing, modifying structures and deleting, can most likely bedone with select SQL or paramitized views. Attitude is Everything
 
No, I do use Visual Foxpro, but as you can tell, I am an "old time" programmer.

I started out about 15 years ago and haven't kept up with the groove.

Most of the work I do is old fashioned direct mail too. Lots of data cleanup

I did figure it out. Thanks for everything!

Elena
 
EBOUGHEY,

In your original code:
.
.
.
repl all QUANTITY with ALLTRIM(CCOUNT)

You are now positioned at EOF()

SKIP next &QUANTITY &&... can't go past EOF()
DELETE REST &&... no more to delete
COPY TO overs FOR DELETED()
pack
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top