Information
This version of the product has reached end of support. The documentation is available for your convenience. However, you must be logged in to access it. You will not be able to leave comments.

Java example--dynamic joins



private void queryPrinterAndComputer(ARServerUser arConnection) throws ARException
{
RegularQuery query = new RegularQuery();

// Add Printer and Computer forms as sources.
QuerySourceForm printerForm = new QuerySourceForm("Printer");
QuerySourceForm computerForm = new QuerySourceForm("Computer");
query.addFromSource(printerForm);
query.addFromSource(computerForm);

// Create join qualifier, which is used to generate the SQL query's
// ON clause.
ArithmeticOrRelationalOperand field1 =
   new ArithmeticOrRelationalOperand(536870914, printerForm);
ArithmeticOrRelationalOperand field2 =
   new ArithmeticOrRelationalOperand(536870914, computerForm);
RelationalOperationInfo relOp =
   new RelationalOperationInfo(RelationalOperationInfo.AR_REL_OP_EQUAL,
   field1, field2);
QualifierInfo joinQual = new QualifierInfo(relOp);
computerForm.setJoin(printerForm, IQuerySource.AR_MULTI_SCHEMA_JOIN_INNER,   
   joinQual);

// The following fields are included in the results. This parameter
// generates the SQL query's SELECT list.
query.addFromField(1, printerForm);          // Printer entry ID
query.addFromField(536870913, printerForm);  // Printer name
query.addFromField(536870914, printerForm);  // Printer ID
query.addFromField(536870915, printerForm);  // Printer type

query.addFromField(1, computerForm);          // Computer entry ID
query.addFromField(536870913, computerForm);  // Computer name
query.addFromField(536870914, computerForm);  // Computer ID

// The following SortInfos are used to generate the SQL query's ORDER BY
// clause. It specifies to sort first on the Printer ID field and then on
// the Computer ID field.
query.addSortByInfo(new SortInfo(536870914, printerForm,
   Constants.AR_SORT_ASCENDING));
query.addSortByInfo(new SortInfo(536870914, computerForm,
   Constants.AR_SORT_ASCENDING));

// 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*

AR System 21.05