Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding records to views, parent tables
Message
De
13/10/1999 11:07:04
 
 
À
13/10/1999 10:59:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00275810
Message ID:
00275846
Vues:
20
Thank you once again.


>Hi Mary-Ann,
>
>You treat views like if they were tables. You insert the parent record first, the insert all the childs in the corresponding views. You start with the parent first, because you may have a relation integrity rule that prohibit inserting a child without a parent.
>
>To be sure that all records will be saved, you can include all the TableUpdate() inside a BEGIN TRANSACTION...END TRANSACTION loop.
>
>Example:
>
INSERT INTO Parent VALUES (...)
>INSERT INTO Child1 VALUES (...)
>...
>INSERT INTO Child2 VALUES (...)
>...
>BEGIN TRANSACTION
>
>IF TableUpdate(.T., .F., "Parent")
>   IF TableUpdate(.T., .F., "Child1")
>      IF TableUpdate(.T., .F., "Child2")
>         END TRANSACTION
>      ELSE
>         ROLLBACK
>      ENDIF
>   ELSE
>      ROLLBACK
>   ENDIF
>ELSE
>   ROLLBACK
>ENDIF
Of course, you may want to display a message if the transaction fail.
>
>HTH
>Really missing something. When you have a database with say, six tables that are all related, I figured the best way to work with the information is to create views of each. Having trouble when you want to add a record to the parent table (which then also needs to add a record to all the child tables). I am Inserting Into the view that comes from the primary/parent table. Do I also need to insert to all the child views? Bottom line, what is the best way to add a record to the Parent table and all the related child tables?
"Live Well, Laugh Often, Love Much..."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform