Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updateable View problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00583933
Message ID:
00583940
Vues:
28
>Hi,
>
>I'm going round in circles so some help would be appreciated.
>
>I have an Updateable view who's base table has a unique ID (from a lookup table), the base table has a default value that is a function that gets the next ID - that's all fine however when I add a record to the view it doesn't have the default value in it so I've set the same call in the default value of the view - how I'm finding that the ID is incrementing twice!
>
>How should I be doing this?
>
>Thanks in anticipation
>Caroline

Do not set the default value in the view. Instead make a call to the procedure that generate the unique ID before adding the new record to the view:

lnID = GetNextID('MyTable')
insert into my view ( KeyID ) values ( lnID )

You will need to make this ID field in your view updatable to prevent the firing of the Default value function in the base table.

You should only have to populate this ID if you need it immediately for FK in child tables. Otherwise, do not specify the default value in the view and do not make it updatable. The PK field will automatically be filled in when you TableUpdate(). IOW, it is OK for that ID field to be zero while you work with the data unless the PK is needed as a FK in child tables.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform