Parent Attribute
Type
Constant String
Since
1.2
Description
Whenever you manually define the SQL Parent-Expression for a Keyloader, it will sort the new loaded key into the hierarchy by search parent key with the ID defined by the Parent SQL-Expression. In some case you don't known the parent's ID but only one of it attributes (maybe the technical id, it's product-number etc.). In this case you can define with which attribute you want to search the parent key (of course, the Parent SQL-Expression must then contain the corresponding value).
Examples
See the following example-tables CATEGORY and PRODUCT:
| CATEGORY_ID | NAME |
| 1 | BEER |
| 1 | WINE |
| PRODUCT_ID | CATEGORY_ID | NAME |
| 1 | 1 | LIGHT BEER |
| 2 | 1 | STRONG BEER |
| 3 | 2 | WHITE WINE |
| 4 | 2 | RED WINE |
Now imagine two SQL-Keyloaders, the first one loading the categories:
- SQL-Expression = "CATEGORY.NAME"
- SQL-Attribute with name "CategoryID" and SQL-Expression "CATEGORY.CATEGORY_ID"
And the second loader for the products:
- SQL-Expression = "PRODUCT.NAME"
- Parent SQL-Expression = "PRODUCT.CATEGORY_ID"
- Parent Search-Attribute = "CategoryId"
Now the second loader would sort it's keys correctly into the hierarchy without knowing the ID (name) of their parents, because it uses the CategoryId (which is available in the PRODUCT-table) to search the parent keys.
See also
Parent Trim, Parent SQL-Expression
