Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parent/Child views - newbie Q
Message
 
À
02/09/1997 19:23:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00048152
Message ID:
00048203
Vues:
18
>Newbie question alert ;-)
>
>I am trying to create a simple parent/child relationship on a data-entry form.
>Copying the OrderEntry form of the Tastrade example I was able to do this with my tables. However, I cant figure out how to do this with views of the tables (I was advised that I should use use views throughout to facilitate later upscaling the database to a server).
>
>Should I be using a view of the parent table AND a view of the child table in the dataenvironment, or should I be using one view of the two tables combined??? Since views dont have indexes like tables, how do I specify the relationship between the parent/child views???
>
>I've tried both approaches with no success - the fields of the parent view appear, but no child records are displayed and I cant add another :-(
>
>What should I put in the 'Linkmaster', 'childorder', etc methods of the child grid???
>
>Any suggestions/guidance welcome
>
>Martin

Martin, I'd use one view with data for both the parent and the child. If your grid is showing JUST the data for a single parent record (such as showing contacts for a given company) you should use a parameterized view.

Your grid will link the parent to the child by the parent's primary key, which should be the child's foreign key. The resulting SQL would look like:
SELECT parent.company, parent.address, child.name, child.phone;
   FROM parent, child;
   WHERE parent.IDCODE = child.IDCODE;
   INTO cursor VUTEMP;
   ORDER by COMPANY
If you want a parameterized view which would show only one parent company:
SELECT parent.company, parent.address, child.name, child.phone;
   FROM parent, child;
   WHERE parent.IDCODE = child.IDCODE;
   AND parent.idcode = ?cID;
   INTO cursor VUTEMP;
   ORDER by COMPANY
Either way, you get all of the child records - one record in the resulting cursor for each child, with duplicate information for the parent. No indexes, no relations.

In the grid, you don't need to set the Linkmaster etc. properties, because you're only using 1 table.

Hope this will get you started.

Barbara
Barbara Paltiel, Paltiel Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform