xquery - Passing results to a a variable -
alright let me begin saying new xquery. started learning 2 days ago. task involves using 3 separate xml files contain tables.
the first file named dependent.xml contains these fields: essn, dependent_name, relationship.
the second file named employees.xml contains these fields: fname, lname, ssn, dno
the third file named department.xml contains these fields: dname, dnumber, mgrssn
so relationships between these tables are: essn = ssn, ssn = mgrssn , dno = dnumber.
i need return list of dependents, along corresponding employee , corresponding manager of employees. code looks far:
{ $d in doc("../company/dependent.xml")//dependent, $e in doc("../company/employee.xml")//employee $d/essn = $e/ssn return <dependent name="{ $d/dependent_name }" fname="{ $e/fname }" lname="{ $e/lname }" /> }
this gives me list of dependents , corresponding employee, point.
the problem managers employees names in employee table. need match dno of employees have dependents dnumber in department table in order mgrssn of departments , match mgrssn employee ssn manager names.
my idea store dno of employees dependents i'm getting code in variable , use variable managers departments , use so:
{ $d in doc("../company/department.xml")//department, $e in doc("../company/employee.xml")//employee $d/mgrssn = $e/ssn , $d/dnumber = $**variable** return <manager fname="{ $e/fname }" lname="{ $e/lname }" /> }
problem have no idea how , realize on separate loop. there way can in 1 loop? if there easier way need i'm open suggestions :)
Comments
Post a Comment