Yes, another ormExecuteQueryEntry! I promise my next article will not have anything to do with ormExecuteQuery. While I was searching for an unrelated issues I was coming across posts where people were having issues using the IN operator with ORM. Here is a quick breakdown of how to format the query.
2 //from array
3 in = "'"&arrayToList(someArr,"','");
4 query = ormExecuteQuery("from someTable where someId IN (:ids)",{ids=in});
5 //from query
6 in = "'"&valueList(someQuery.ids,"','");
7 query = ormExecuteQuery("from someTable where someId IN (:ids)",{ids=in});
You get the idea, it all revolves around formatting the section of the IN operator between the parentheses. The parentheses need to be part of the query and not the variable passed in. If you do try it that way than HQL with throw an error.
Follow those instructions will get you where you need to be with the IN operator and ormExecuteQuery
The only issue I had with the IN operator and the HQL was using "NOT IN." No matter how I tried to do this it never produces the correct results, so if anyone has insight into why that might not be working please leave a comment
#1 by Henry Ho on 4/12/11 - 2:40 PM