Question

I'm trying to write an RQL query that does the equivalent of this sql:

select * from some_table t where t.property in (1, 2, 3, 4 ...)

I'm not sure if RQL supports this though. In the oracle docs, there's an example of how to do this on the ID property of a repository item:

ID IN { "0002421", "0002219", "0003244" ... }

but when I try to change ID in this example to the property I want to query on, I get an RQL ParseException.

Does anyone know if this is possible?

Was it helpful?

Solution

this is possible through querybuilder api(see example below). I'm not sure why this is not available through plain RQL though.

QueryExpression thePropertyExpression =     
   theQueryBuilder.createPropertyQueryExpression("postalCode");

String [] zipcodeArray = {"22185", "22183"};

QueryExpression theValueExpression = 
    theQueryBuilder.createConstantQueryExpression(zipcodeArray);

Query theQuery = 
    theQueryBuilder.createIncludesQuery(theValueExpression, thePropertyExpression);

OTHER TIPS

From the ATG Documentation the RQL Grammar includes a specific comparison query for ID IN so changing ID to another property will not parse properly thus your ParseException.

Looking further down the Grammar document you'll find the ComparisonOperator. The one of particular interest is the INCLUDES ANY.

An example around its use (from the docs)

interests INCLUDES ANY { "biking", "swimming" }

This is equivalent to:

(interests INCLUDES "biking") OR (interests INCLUDES "swimming")

So this may work, as long as you are searching scalar properties.

So that leaves you with the final option, which you are probably trying to avoid which is to create a big OR condition, which is the way I normally would do it, since you'll have to go through a loop to build up your IN statement anyway.

Answer from radimpe is correct and is straight from oracle docs. You can do an INCLUDES ANY query for your requirement. It works for strings. For ex. if you are searching for users with first name in Alex or Brian you can write in RQL :

firstName INCLUDES ANY {"Alex","Brian"}

Link here : http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGRepositoryGuide/html/s0305multivaluedpropertyqueries01.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top