SQL IN clause in XPATH/OQL, and return the result as an Object instead of String
0
Hey guys, Trying to execute the below equivalent of XPATH/OQL, however it doesn’t work. SELECT em FROM EmployeeMaster em WHERE em.EmpID IN (‘101’, ‘105’, ‘170’, ‘240’, ‘770’); Problem with XPATH : It never accepts IN clause at all. Problem with OQL : It didn’t return the List<EmployeeMaster>. Instead it returned a long string that contains the resultant 4-5 odd rows. I just need the IN clause to be executed as a constraint, and the return value to be a list of EmployeeMaster equivalent to below JSON. { { 101, “Vishal”, “Pune”, “Solutions Architect” } , { 105, “Maya”, “Delhi”, “Developer” } , { 170, “Stephan”, “London”, “Lead” } , { 240, “Emily”, “New York”, “Quality Analyst” } , { 770, “Amelia”, “Munich”, “Sr Developer” } } Thanks in advance !
asked
Vishal Kapurkar
1 answers
0
You can use ‘or’ clauses in XPath to mimic this.
So if your EmployeeMaster entity is in MyFirstModule, something like this should retrieve the objects with those matching EmpId attributes.
//MyFirstModule.EmployeeMaster[EmpId='101' or EmpId='105' or EmpId='170' or EmpId='240' or EmpId='770']
There are more details on XPath constraints in the Mendix documentation that explain things in greater depth.