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

syncronising latest data and table structures

Status
Not open for further replies.

codetyko

Programmer
May 26, 2001
73
MY
Sometimes when doing an upgrade to an existing program, you will add additional fields or even add a new table altogether as well as create new index keys.

I want to create a program that

1) records the structures of the new tables as well as existing ones

2) At the clients' place recreate the new tables in a separate directory where these tables are obviously empty.

3) Run through (scan) the list of "old" tables and if the same table name is found in the "new" table directory, append the records to the new tables until all the tables are updated. If the table does not exist, copy it to the old directory.

4) When done, transfer the newly updated tables to the old directory.

Would appreciate any tips in approaching this problem in the best possible way. Thanks in advance.
 
Hi Codetyko,

Here's how I approach those issues : upon startup, i copy the files with the new structure from the install dir to the data directory.
Then i zap the new file, just to be sure ; and then I APPEND FROM [the old file]
If necessary, I also run a separate procedure that will "fill in" the info for the extra fields, preferably with a REPLACE ALL for speed.

If some of the old fields have to go, but new info in the new structure is based on the contents of those old fields, I'll first append into an in-between datafile which contains both the fields that are new and the fields that are to be deleted.
Then I do my REPLACE routines, and finally append into the new datafile structure.

Final step is to either remove the old datafile with DELETE FILE, or RENAME it. (Tip: if you rename it to a different path, the file will be _moved_)
Last but not least, rename the new file to the standard filename for that database.

Best regards,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish at the same time." (De Rochefoucald)
 
tough project, but doable; You will need a couple of commands and some for loops.

adir(filepath_oldfiles,listof_oldfiles) filenames
and adir (filepath_newfiles,listof_newfile)

for i = 1 to alen(listof_oldfiles)
copy struc to array old_struc
for j = 1 to alen(listof_newfiles)
for k = 1 to alen(old_sturc)

ect...



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top