Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rebuilding tables
Message
From
26/01/2000 18:06:53
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Rebuilding tables
Miscellaneous
Thread ID:
00323249
Message ID:
00323249
Views:
62
I am having troubles figuring out a rebuild program that I am using. I keep getting Error #111. Cannot update cursor.

Here is what I am doing. I am finding which tables are in the datadict and trying to copy the data from the old table into a new structure.

Here is my code.

* Determine which files to Rebuild
if empty(FileList)
select distinct dbf_name, d_template;
from datadict ;
order by dbf_name ;
into cursor dbf_list
else
select distinct dbf_name, d_template;
from datadict ;
where alltrim(dbf_name) $ m.FileList ;
order by dbf_name ;
into cursor dbf_list
endif

* Begin Processing
select dbf_list
scan

* Get table, template, and CDX names
alias = strtran(alltrim(dbf_list.dbf_name),".DBF","")
template = dbf_list.d_template
currdbf = alias+".DBF"
currcdx = alias+".CDX"

* Report progress
activate window files
? currdbf
activate window progress
clear

* Create a back up of this table and index
set safety off
? "Creating backup files:"
copy file (currdbf) to (strtran(currdbf,".DBF",".DB~"))
? " "+strtran(currdbf,".DBF",".DB~")
if file(currcdx)
copy file (currcdx) to (strtran(currcdx,".CDX",".CD~"))
? " "+strtran(currcdx,".CDX",".CD~")
endif
set safety on

* Create the new structure in memory
? "Creating new structure"

select distinct * ;
from datadict ;
where datadict.d_template == template;
having datadict.field_name != "Proxy" ;
into array dbf_struc ;
order by field_ord

create cursor tempdbf from array dbf_struc
select tempdbf
go top

* Copy the data from the old table into the new structure
? "Copying old data"
if file(currdbf) *THIS IS WHERE I GET THE ERROR
append from (currdbf) && This is where we will likely have an error
endif

* If we had an error that couldn't be fixed, Say so and exit.
if GotError <> 0
Wait Window "Rebuild found a problem it couldn't fix in file: "+upper(Currdbf) Timeout 5
wait window "Error #: "+alltrim(str(goterror))+" Message: "+alltrim(message()) Timeout 5
RETURN -1
endif

Any help would be appreciated,

Thanks,
Tyler
Next
Reply
Map
View

Click here to load this message in the networking platform