Java example--value set queries


This is an example to use a value set query.

In this example, the login user name is InSubqueryUser. The query operates on the InSubqueryPermissions1 form and performs the IN subquery on the InSubqueryPermissions3 form. The example assumes that both forms are populated with the appropriate data. 


// inNotInOption is either RelationalOperationInfo.AR_REL_OP_IN
// or RelationalOperationInfo.AR_REL_OP_NOT_IN
private void queryUsingSubquery(int inNotInOption, ARServerUser arConnection) throws ARException
{
// Create subquery part first.
ValueSetQuery subquery = new ValueSetQuery();

// Add InSubqueryPermissions4 form as the subquery source.
QuerySourceForm perm4Form = new QuerySourceForm("InSubqueryPermissions4");
subquery.addFromSource(perm4Form);

// The subquery's return value.
subquery.addFromField(536870913, perm4Form);

// Create regular query.
RegularQuery query = new RegularQuery();

// Add InSubqueryPermissions1 as the from source.
QuerySourceForm perm1Form = new QuerySourceForm("InSubqueryPermissions1");
query.addFromSource(perm1Form);

// Set the regular query's return fields.
query.addFromField(1, perm1Form);
query.addFromField(536870913, perm1Form);
query.addFromField(536870914, perm1Form);

// Set value set query now.
ArithmeticOrRelationalOperand field =
   new ArithmeticOrRelationalOperand(536870913, perm1Form);
ArithmeticOrRelationalOperand arethQuery =
   new ArithmeticOrRelationalOperand(subquery);
RelationalOperationInfo relOp =
   new RelationalOperationInfo(inNotInOption, field, arethQuery);
QualifierInfo subqueryQual = new QualifierInfo(relOp);
query.setQualifier(subqueryQual);

// Call routine.
List<QuerySourceValues> results =
   arConnection.getListEntryObjects(query, 0, 0, false, null);
}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*