Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get foreign keys
Message
From
07/06/2022 10:09:16
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
07/06/2022 09:23:37
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01684430
Message ID:
01684458
Views:
42
>>>>>>Hi All,
>>>>>>
>>>>>>while trying to fix a corrupted DBC I need to redo some indexes. There is just the DBC, nothing else. While I know to get the information about the tags via ATAGINFO(), how do I get information about foreign keys? This is odd. I know I can mimic low level through the DBC, but is there nothing build in?
>>>>>>
>>>>>
>>>>>See if ADBObjects() gives you what you need.
>>>>>
>>>>>Tamar
>>>>
>>>>Hi Tamar,
>>>>
>>>>Yes, thank you this is the information I need.
>>>>
>>>>Ends up directly with the next question. How to programaticaly create referential integrity ? If the relation is lost integrity is lost too. ADBObjects() gives me waht to do, but I aside from hacking the DBC I have no chance. This is a database of 379 tables, 212 views, 96 relations - impossible to work this in MODI DATA .
>>>
>>>Do you have Stonefield Database Toolkit? It does this, so you could look at Doug's code there.
>>>
>>>To answer the specific question, look at the REFERENCES and FOREIGN KEY clauses of ALTER TABLE.
>>>
>>>Tamar
>>
>>Hi Tamar,
>>
>>No, I don't have Stonefield. And on help to ALTER TABLE I do not see how to set referential integrity, as far as I understand it. Searching for referential integrity in help reveals nothing aside the use of interface.
>>
>>Lutz
>
>The Help file under ALTER TABLE has this:
>
>REFERENCES TableName2[TAG TagName1]
>Specifies the parent table to which a persistent relationship is established. The parent table cannot be a free table.
>
>The TagName1 parameter clause specifies an index tag name for the parent table in TableName2. Index tag names can contain up to 10 characters. If you omit the TAG clause, the relationship is established using the primary index key of the parent table. If the parent table does not have a primary index, Visual FoxPro generates an error.
>
>Under the Examples in that Help Topic:
>
>* Example 4
>
>ALTER TABLE Orders;
>
>   ADD FOREIGN KEY Cust_id TAG Cust_id REFERENCES Customer
Hi Frank,

That is the easy part. :) This will add the relationship only.

My problem is referential integrity.
Open a database with foreign keys using OPEN DATA .. EXCL, then MODI DATA. Right click a relationship (the line), select "Edit Relationship integrity".

There are three pages where you can set referential integrity for the relationship. To do this using code is the goal.

You get the actual setting using ADBOBJECT(laArra,'RELATION'), as Tamar suggested, but how to set?

Tip:
Help on ALTER TABLE ... ADD FOREIGN KEY is wrong anyway. COLLATE is placed wrong. See https://github.com/VFPX/HelpFile/issues/18

I do not use that, but a friend comes up with a corrupted database made by a framework that creates this stuff. I know what to set, but not how, and on IDE it is a no go. To many elements.

Lutz

Update:
The field in the DBC, RIINFO, has a description as .. used by the Referential Integrity Builder (in 60dbc.frx) but automatically used by VFP.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform