OK what am I doing wrong ?
The question is, Why am I getting the Fox error "The uniqueness of Primary Key Violated" from what I have done below ??
Trying to create a database to document the classes of a Very Large application.
I created 3 tables
LIBRARIES - 21 unique records for the different Class Libraries in the Application.
CLASSES - ends up with 5192 records
PURPOSES - 1to1 Relation with CLASSES with memo fields for purpose & Reason (plus audit fields for new , obsolete, updated , etc)
Basic Structure of CLASSES and PURPOSES was created with
use c:\xxxx\(classname.vcx)
copy stru to CLASSES
copy stru to PURPOSES
Modified the structure and changed the following MEMO fields to VarChar's. Names did not change but I dropped all the reserved fields.
UNIQUEID=C(15)
CLASS = VC(25)
CLASSLOC =VC(25)
BASECLASS=VC(25)
OBJNAME=VC(50)
PARENT=VC(50)
FOLDER M (Added it)
code to populate table CLASSES is
CLOSE ALL
USE CLASSES EXCLU
ZAP
COPY STRU TO LIBTEMP
SELECT 0
USE LIBRARIES
SCAN ALL
lcFolder = ADDBS(UPPER(ALLTRIM(LIBRARIES.FOLDER)))
lcClass = UPPER(ALLTRIM(LIBRARIES.CLASSLOC))
lcFileName = lcFolder + lcClass + ".VCX"
SELECT 0
USE (lcFileName)
COPY TO libtemp
USE libtemp EXCLUSIVE
replace ALL LIBTEMP.FOLDER WITH lcFolder
replace ALL LIBTEMP.CLASSLOC WITH lcCLass
USE
SELECT CLASSES
APPEND FROM LIBTEMP
SELECT LIBRARIES
ENDSCAN
USE IN LIBRARIES
SELECT CLASSES
DELETE ALL FOR EMPTY(class)
PACK
..
.. code to upper() all the values in the VarChar fields..
.. code to create regular indexes ..
..
CLOSE ALL
USE PURPOSES
APPEND FROM CLASSES
.. (Played with the Audit fields)..
CLOSE ALL
I then created the database ClassLibrary and added the 3 tables CLASSES, LIBRARIES, PURPOSES
close databases all
close tables all
open database CLassLibrary exclusive
use CLASSES EXCL
Modi Stru
tried to set the index on UNIQUEID+CLASSLOC+OBJNAME as Candidate or Primary. Here is where I get the error.
But if I do the following in the command window
set deleted off
set unique ON && (ON or OFF has no effect on the outcome)
INDEX ON UNIQUEID+CLASSLOC+OBJNAME TAG UPRIKEY UNIQUE
set order to
delete all
set order to uprikey
recall all
set unique OFF
set order to
browse for deleted()
No records are shown so there are no duplicates in the table
I've have done this before to document other applications (none as big as this) without problems. First time I've done it in VFP9 using VarChar instead of Char fields. Any Ideas why I can not get the Primary / Candidate Index ?
David W. Grewe Dave
The question is, Why am I getting the Fox error "The uniqueness of Primary Key Violated" from what I have done below ??
Trying to create a database to document the classes of a Very Large application.
I created 3 tables
LIBRARIES - 21 unique records for the different Class Libraries in the Application.
CLASSES - ends up with 5192 records
PURPOSES - 1to1 Relation with CLASSES with memo fields for purpose & Reason (plus audit fields for new , obsolete, updated , etc)
Basic Structure of CLASSES and PURPOSES was created with
use c:\xxxx\(classname.vcx)
copy stru to CLASSES
copy stru to PURPOSES
Modified the structure and changed the following MEMO fields to VarChar's. Names did not change but I dropped all the reserved fields.
UNIQUEID=C(15)
CLASS = VC(25)
CLASSLOC =VC(25)
BASECLASS=VC(25)
OBJNAME=VC(50)
PARENT=VC(50)
FOLDER M (Added it)
code to populate table CLASSES is
CLOSE ALL
USE CLASSES EXCLU
ZAP
COPY STRU TO LIBTEMP
SELECT 0
USE LIBRARIES
SCAN ALL
lcFolder = ADDBS(UPPER(ALLTRIM(LIBRARIES.FOLDER)))
lcClass = UPPER(ALLTRIM(LIBRARIES.CLASSLOC))
lcFileName = lcFolder + lcClass + ".VCX"
SELECT 0
USE (lcFileName)
COPY TO libtemp
USE libtemp EXCLUSIVE
replace ALL LIBTEMP.FOLDER WITH lcFolder
replace ALL LIBTEMP.CLASSLOC WITH lcCLass
USE
SELECT CLASSES
APPEND FROM LIBTEMP
SELECT LIBRARIES
ENDSCAN
USE IN LIBRARIES
SELECT CLASSES
DELETE ALL FOR EMPTY(class)
PACK
..
.. code to upper() all the values in the VarChar fields..
.. code to create regular indexes ..
..
CLOSE ALL
USE PURPOSES
APPEND FROM CLASSES
.. (Played with the Audit fields)..
CLOSE ALL
I then created the database ClassLibrary and added the 3 tables CLASSES, LIBRARIES, PURPOSES
close databases all
close tables all
open database CLassLibrary exclusive
use CLASSES EXCL
Modi Stru
tried to set the index on UNIQUEID+CLASSLOC+OBJNAME as Candidate or Primary. Here is where I get the error.
But if I do the following in the command window
set deleted off
set unique ON && (ON or OFF has no effect on the outcome)
INDEX ON UNIQUEID+CLASSLOC+OBJNAME TAG UPRIKEY UNIQUE
set order to
delete all
set order to uprikey
recall all
set unique OFF
set order to
browse for deleted()
No records are shown so there are no duplicates in the table
I've have done this before to document other applications (none as big as this) without problems. First time I've done it in VFP9 using VarChar instead of Char fields. Any Ideas why I can not get the Primary / Candidate Index ?
David W. Grewe Dave