Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple table update view insert
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00552274
Message ID:
00552355
Vues:
10
This message has been marked as the solution to the initial question of the thread.
Hi!

take a look to the cursorgetprop() and cursrsetprop(). You can set there many parameters of view include the list of the updatable fields and key fields. In your case, when inserting new record, you can temporarily change these parameters so update is performed only for first table. Then return them back.

However, I wondered - did you tested updating change of the second table when there are no record in second table for current record from first table? There will be all NULL values include in the key field for second table, thus VFP will not be able to find a record because key field contains NULL. In addition, how then you will add new record to second table for first table? It is quite problematic from the logical point of view.

As you see, better do not use view based on 2 tables when you require to allow no record in second table related to first table. Just split them to two views, one is a main view (first table), another is a child view (second table). Do query in the child view based on parameter from the first table - ID used to relate tables. Then requery second view after each record movement in main view. This way you will get less data from server and will not bother with view with 2 tables. Child table will contain always required record, or no record. And you always will be able to insert record into main view, child view or into both.

HTH.

>I've got a view that can update 2 tables. Updates of existing records work fine, but every time I insert a new record into the view and do a tableupdate, a record gets added into both tables.
>
>The view is defined with optimistic table buffering. One of the 2 tables is primary. A new record in this table will always reference an existing record in the other (secondary) table, the way my app is designed. The one field in the secondary table I want to update is a foriegn key reference to the primary table.
>
>In order to implement this functionality, must a break the one view up into two views?
>
>Seems like you aught to be able have a multiple table update view that doesn't always add a new record to all updatable tables on a view insert -- or am I missing something?
>
>TIA
>
>Doug
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform