|
Relationships are a powerful tool in ACL to associate data between two tables. It can be effectively done via the GUI interface within ACL, which uses a mapping structure similar to Access. Or it can be done via a script. Below is the model for how to write relationships for both the basic: Parent to Child relationship and the more advanced: Parent to Grandchild relationship. ACL can relate up to 17 tables in this manner.
The Basic Relationship- Parent to Child
DIALOG (DIALOG TITLE "User Dialog" WIDTH 472 HEIGHT 340 ) (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) (TEXT TITLE "Parent Table" AT 24 76 ) (TEXT TITLE "Child Table" AT 24 112 ) (ITEM TITLE "f" TO "t_parent" AT 120 72 WIDTH 285 HEIGHT 239 ) (ITEM TITLE "f" TO "t_child" AT 120 108 WIDTH 285 HEIGHT 212 ) (TEXT TITLE "Define Index Name" AT 24 160 ) (EDIT TO "v_name1" AT 120 156 WIDTH 285 )
OPEN %t_parent%
DIALOG (DIALOG TITLE "User Dialog" WIDTH 498 HEIGHT 463 ) (BUTTONSET TITLE "&OK;&Cancel" AT 396 24 DEFAULT 1 ) (ITEM TITLE "C" TO "v_parent" AT 120 108 WIDTH 335 HEIGHT 312 ) (TEXT TITLE "Parent Field" AT 24 112 )
OPEN %t_child%
DIALOG (DIALOG TITLE "User Dialog" WIDTH 479 HEIGHT 326 ) (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) (ITEM TITLE "C" TO "v_child" AT 132 96 WIDTH 284 HEIGHT 215 ) (TEXT TITLE "Child Field" AT 24 100 )
i_name = "%i_name1%"
INDEX on %v_child% to "%i_name%" Set INDEX TO "%i_name%"
OPEN %t_parent% DEFINE RELATION %v_parent% WITH %t_child% INDEX %i_name%
Relating to grandchildren tables
Field_B_to_C is the field that you have in common in the relationship on tables B and C. Field_A_to_B is the field that you have in common in the relationship on table A and B. I_tableC and I_tableB are the indexes that I've defined.
OPEN TABLEC INDEX ON Field_B_to_C TO "i_TABLEC" SET INDEX to "i_TABLEC" COM creating an index on a computed field in the TABLEB file OPEN TABLEB INDEX ON Field_A_to_B TO "i_TABLEB" SET INDEX to "I_TABLEB"
COM creating the relationships with TABLEA as the parent Table. OPEN TABLEA DEFINE RELATION Field_A_to_B WITH TABLEB INDEX i_TABLEB
COM creating a relationship with a child of a child file. OPEN TABLEA DEFINE RELATION TABLEB.Field_B_to_C WITH TABLEC INDEX i_TABLEC
COM extract fields from tableA with just the field name. For tableB or TableC place the table and a period before the fieldname. You can sort the extracted fields as you wish. OPEN TABLEA EXTRACT fieldname tableB.fieldname tableC.fieldname TO extracted_table
|