Importing Parent-Child Data with XML Import |
Parent-child data can be imported using XML.Import. For example: when the parent key is generated key. Example: INVOKE XML.IMPORT WITH SELECT '<?usoft-xml version="1.0" action="multi-tables-import" use-io-formats="no" verify-original-values="no" return-corrected-records ="yes"?> <MultiImport> <Companies> <COMPANY NAME="Company A" COMPANY.id="1"/> </Companies> <Departments> <DEPARTMENT NAME="Engineering" DEPARTMENT.id="2"> <RELATE ROLE="HAS" href="#1"/> </DEPARTMENT> <DEPARTMENT NAME="Support" DEPARTMENT.id="3"> <RELATE ROLE="HAS" href="#1"/> </DEPARTMENT> </Departments> <Employees> <EMPLOYEE NAME="Employee1" > <RELATE ROLE="HAS" href="#2"/> </EMPLOYEE> <EMPLOYEE NAME="Employee2" > <RELATE ROLE="HAS" href="#3"/> </EMPLOYEE> </Employees> </MultiImport>' Where:
NOTE: To improve the performance of xml.import make sure that parent records are before child records in your XML document when using id-href constructions. An id can follow an href only if the foreign key of the child record is not part of the primary key or if foreign key is not mandatory, otherwise the href must follow the id (child record must be after the parent record in the XML document). |