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

deleting the database with zap command w/o knowing names of table

Status
Not open for further replies.

rehanqadri

Programmer
Joined
Jan 31, 2004
Messages
40
Location
PK
subject: deleting the database with zap command

i want to create a general exe file so that i could completely zap all tables in my project. so that at the end of financial year my users could start new financial year from scratch.

i have used zap command but it requires to first open the file and then issue zap command. is there any logic so that my program could locate dbfs in the current directory and opens them one by one so that i could apply a single operation to all the tables in my database (like the Zap command).

thank you.
 
Hi,

Here is some code for you to test:

Code:
close data
= adir(fileArray,"*.dbf")
for i=1 to alen(fileArray,1)
    tableName = fileArray(i,1)
    use &tableName exclusive
    zap
    ? &tableName, reccount()
endfor

But you would need to take care of possible errors like:
Not a database file.
Structural CDX file not found.
File access denied.
...
and don't forget to backup.
 
Create your tables with the start of each table name being the 2 digits corrresponding to the year.
Have a routine in your program to create the new tables at the start of each year. eg 04table1.DBF etc.

You can use the MS-Dos command DEL or ERASE using the wild card corresponding to the year suc as ERASE 04*.*

Is it good practice to delete all your tables? Using the above technique you can preserve your tables.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top