Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a Cursor from 2 tables, related or not
Message
De
27/12/1999 19:48:46
Jill Derickson
Software Specialties
Saipan, CNMI
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Creating a Cursor from 2 tables, related or not
Divers
Thread ID:
00309015
Message ID:
00309015
Vues:
58
Hello all,

I want to create a cursor with information about defendants, victims and defendant-victim relationships, if any, for a case.

The tables involved are:
defendants w/primary key DefID (and tags caseID and PersonID)
victims w/primary key VictimID (and tags caseID and PersonID)
people w/primary key PersonID
vicRelations with foreign keys DefID and VictimID (and RelationID tag)
RelationDescriptions w/primary key RelationID

Victims and defendants in a case may not be related, or they may have one or more relationships (example, "brother", "employer"). If there is no relationship, I still want to display the victim, w/a blank relationship.

I want to create a cursor, to display in a grid, that is linked to a master by DefID.

Ideally, I would do this in a view, but it seems too involved. What I've done is:

1. created a cursor, cDisplayVictims ( VictimName C(57), Relation C(20), DefID I ) to display the result.

2. Select all the relations for the defendants in the case into a cursor, cTempRelations, then create an INDEX ON ALLTRIM( STR( DefID ) ) + ALLTRIM( STR( VictimsID ) ) Tag DefID [is there a better way to create a tag on 2 integer fields?]

3. Select victim and defendant info, into a cursor, cTempVictims, with one record for each possible victim-defendant combination (victim name, victimID, DefID), then SET RELATION TO ALLTRIM( STR( DefID ) ) + ALLTRIM( STR( VictimsID ) ) INTO cTempRelations

4. Scan cTempVictims, inserting records into cDisplayVictims - if no records in cTempRelations, insert a record w/a blank relation, otherwise, insert one record for each relation in cTempRelations.

And it works...but, is there a simplier/more elegant method?

TIA for any input...J
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform