Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary Key Problem
Message
 
 
À
24/11/1999 10:06:43
Jimmy Ditta
Twin City Electronics
Monroe, Louisiane, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00294634
Message ID:
00295168
Vues:
27
>You're right, table3 is still not being appended. Let me throw this into the mix . . . the regular key ID field in table2 (which IS being appended) is not getting the ID that table1 (with the primary key) is getting. table 2 is getting zeros. Any clues there?

The append problem is directly related to Uniqueness of ShipDataID being violated because the IDs are zero in the first 2 tables. When you add a new record to the first 2 tables you need to use your KeyID generator to populate these fields with unique IDs. This will also be a problem if you append blank more than once without setting the ID to a non-zero ID.

I always default my primary key fields to a function that calls a stored procedure in the DBC. For me this default value for the field is GetPrimaryKey("MyTable"). In the stored procedures of the DBC, I have the following:
function GetPrimaryKey
*
* lcTable is the table that needs a Key ID based on the 
* count in the KOUNTER.DBF table
*
lParameter lcTableName
if parameters() = 0
	return .f.
endif
if type("lcTableName") <> "C" or empty(lcTableName)
	return .f.
endif
local lcSelect
lcSelect = select()
if !used("Kounters")
	use Kounters in 0
endif
select Kounters
lcTableName = upper(lcTableName)
locate for Kounters.Table_Name = (lcTableName)
if eof()
	insert into Kounters ( Table_Name, Kount ) ;
		values ( lcTableName, 0 )
endif
local lnRetVal, llLocked
llLocked = rlock("Kounters")
do while !llLocked
   llLocked = rlock("Kounters")
endif
lnRetval = Kounters.Kount + 1
replace next 1 Kounters.Kount with Kounters.Kount + 1
unlock in Kounters
select (lcSelect)
return lnRetVal
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform