Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reindexing and append
Message
From
09/07/2006 20:53:11
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 2000
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01134653
Message ID:
01134827
Views:
14
>Chris
>
>AUTOINCERROR off, will surely get you passed the read-only error message. However the Append From will renumber the records because of the autoinc set on the pk. That makes since, as you would want new records numbered during Append from. However, renumbering, backup versions not a good thing.
>
>The next thought was to drop the pk (alter table DROP pk - dropping removes the index not the field) then Append from xxx, then put the primary key back together (alter table ADD pk) then AUTOIncError ON.

I think (hope) the following code sample accomplishes what you want, not by dropping the PK, but by removing and then adding the AUTOINC property of the field.
CLOSE DATABASES ALL
CLEAR
ERASE TempDB.*
ERASE TempDBF.*
ERASE TempBak.*

CREATE DATABASE TempDB
CREATE TABLE TempDBF (TempPK I NOT NULL AUTOINC PRIMARY KEY, OldPK C(1))
INSERT INTO TempDBF (OldPK) VALUES ("1")
INSERT INTO TempDBF (OldPK) VALUES ("2")
INSERT INTO TempDBF (OldPK) VALUES ("3")
INSERT INTO TempDBF (OldPK) VALUES ("4")

COPY TO TempBak.dbf
ZAP

* Remove AUTOINC property
ALTER TABLE TempDBF ALTER COLUMN TempPK I NOT NULL
APPEND FROM TempBak.dbf
SELECT MAX(TempPK) + 1 FROM TempDBF INTO ARRAY aPK

* Reinstate AUTOINC property
ALTER TABLE TempDBF ALTER COLUMN TempPK I NOT NULL ;
   AUTOINC NEXTVALUE aPK[1] STEP 1
LIST STRUCTURE
BROWSE NORMAL NOWAIT
Chris
Christopher Bohling, Consultant
http://www.ChristopherBohling.com
Previous
Reply
Map
View

Click here to load this message in the networking platform