Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
V6s5 - Creating Relations and their triggers programatic
Message
De
26/12/2003 08:49:30
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00862102
Message ID:
00862111
Vues:
13
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all
>
>How can I go about writing a small prg which creates relations between given tables and their corresponding PK and FK field names?
>
>I would also like to setup RI compatible triggers in the same program.
>
>Please advise of how to go about programming such a utility, or is one already available for downlaods anywhere.

To add procedures to the stored procedures, see APPEND PROCEDURES.

To modify a trigger to a table, see CREATE TRIGGER.

The actual trigger function for RI would have to search the key value, check in related tables, and return .T. or .F., depending on the type of trigger, and on whether the value is found.

For example, for a delete trigger (in the parent table), if the value is found in child tables, the function should return .F. (DELETE is not allowed). Otherwise .T.

For an insert or update trigger (in the child table), if the value is NOT found in the parent table, your function should reurn .F.


If you want to redesign the RI completely, I have an idea that it might be interesting to use a single RI-function for all tables, and use a table-based approach. In other words, have your RI-function check a "relations" table, and search according to the parameters it finds there.

Then, to redefine RI, you don't even need to recompile the stored procedures.


On the other hand, I don't know whether such an effort is worthwhile; you can just as well use the built-in RI.

Greetings,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform