Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically gathering indexs, keys & relationships
Message
From
02/08/2000 15:17:39
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00399648
Message ID:
00400001
Views:
18
The index information will probably have to be gathered by looping through the tables in the database, then looping through each tag on the table., e.g.
ADBOBJECTS(laTable,"Table")
FOR EACH lcTable In laTable
  USE (lcTable)
  FOR ji = 1 TO TAGCOUNT()
    ** store off however
    ** tag name from TAG(ji)
    ** tag expression from SYS(14,ji)
    ** PRIMARY(ji), CANDIDATE(ji), UNIQUE(ji) to find out type
  ENDFOR
  USE
ENDFOR
You can get the relationship information directly from the DBC, provided the DBC is not open exclusively at the time.
SELECT d1.objectname AS table_name, ;
 d2.objectname AS relation_name, ;
 d2.property, ;
 d2.riinfo ;
 FROM mydata.dbc d1 ;
 JOIN mydata.dbc d2 ;
 ON d1.objectid = d2.parentid ;
 WHERE d2.objecttype = "Relation" ;
 INTO CURSOR cuRelations
USE IN mydata
The relationship is stored in the dbc as a child object of the table on the right side of the relationship description. e.g., Table1 has a 1-M or a 1-1 relationship to Table2. The Relation database object is a child of Table2.

The riinfo field indicates the actions to take for the types of changes - "C" for "Cascade", "R" for "Restrict" and "I" for "Ignore". This is 3 characters long - 1st is for Updates, 2nd is for Deletes, 3rd is for Insert. So a value of "CRI" would mean:
Cascade Updates
Restrict Deletes
Ignore Inserts
If the field is empty, Ignore is assumed for all.

In the property field, the leftmost character indicates the type of relationship. Chr(14) indicates a 1-M and Chr(11) indicates a 1-1.
The first readable entry is the Child table index used in the relationship.
The 2nd is the parent table, and the 3rd is the parent index.
How you want to parse this is up to you.
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform