Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing for existing relationship?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Testing for existing relationship?
Divers
Thread ID:
00236537
Message ID:
00236537
Vues:
53
Is there a way in VFP6 to test for a relation that may or may not already exist?

I have a project where I have to pull data from an existing database that was built under FPW26 (still being used - all free tables). The database has a main table and many child tables that hold sports statistics for athletes in different sports. The main table has a field which indicates which table the stat data is in. There will never be more than three of the child tables in use at any one time. I need to be able to open the desired table and set a relation to it if it does not already have one. In the interest of speed, I would prefer not to tear down relations once established.

In the code segment below, I have marked with '->>' the line I would like to use, which gives me an error 'already engaged in a relation'.
Can I test to see if the relation exists and make the desired relation conditional?

------------------------------------------------
** Already in cursor c_Athlete created from main table **
pcSport0 = "reg_"+ ALLTRIM(gen_sc) && Identify main sport table
IF NOT USED (pcSport0)
USE (pcSport0) IN 0 ORDER registr_id && Open table if not already
ENDIF
select (pcSport0)
lnFieldCount0 = AFIELDS(aSport0Fields) && Copy table structure
CREATE CURSOR c_Sport0 FROM ARRAY aSport0Fields && to cursor
SELECT C_Sport0
INDEX ON registr_id TAG registr_id
->> SET RELATION TO registr_id into (pcsport0), registr_id into c_Sport0 IN c_Athlete ADDITIVE && Tie them together
* load record from sport0 table into cursor
SELECT (pcSport0)
...etc....
------------------------------------------------

Thanks,
Neil Preston
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform