Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Buffering, Views and primary keys
Message
 
 
À
22/02/2000 19:42:50
Jill Derickson
Software Specialties
Saipan, CNMI
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00335702
Message ID:
00335742
Vues:
23
>Confused again!!!
>
>I have a table GROUP, w/primary key GROUPID. The primary key is assigned as the default value of GROUPID, w/a call to a GetKey( "GROUP" ) routine. Another table, PACSEA, has one or more entries w/a foreign key of GROUPID.
>
>I need to have the value for GROUPID before I write any records in PACSEA. This must be a common thing that people do, yet I'm having trouble figuring out the sequence.
>
>I am trying to use views to update both tables and am having trouble when creating a new group. Where should the GetKey call be? in the view or in the underlying table, or both?
>
>If it's in both, it seems that a new key is generated when inserting into the view and when inserting into the table.
>
>ANy input is appreciated. J

A common dilema for me as well. Normally, I have views whose PK field is not updatable. However, if I need to know the key when I add a new record to the view [mainly because it is going to be a FK for another view for which I am also adding records], I have to generate the ID first for the view. One option is to use DBSetProp('mytable.mypkfield', 'Field', 'Updatable', .T.) which is fine if you create a temp DBC on each user's computer. OTherwise it is not so good a practice.

If you populate the PK without that field being updatable, a second PK will be generated when you issue TableUpdate(). This too is very bad. For you, since you are using a local view, you need to deal directly with the table first. Then use the view to retrieve the new record[s]. For me, I am using remote views, so I have to have 2 views -- 1 with the PK field updatable and 1 with the PK non-updatable.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform