AttributeTest

An AttributeTest defines a filter condition using an MBO attribute, and supports multiple conditions.

For example, the Java code shown below is equivalent to this SQL query:
SELECT * from A where id in [1,2,3]
Query query = new Query();
AttributeTest test = new AttributeTest();
test.setAttribute("id");
com.sybase.collections.ObjectList v = new com.sybase.collections.ObjectList();
v.add("1");
v.add("2");
v.add("3");
test.setValue(v);
test.setOperator(AttributeTest.IN);
query.where(test);
When using EXISTS and NOT_EXISTS, the attribute name is not required in the AttributeTest. The query can reference an attribute value via its alias in the outer scope. The Java code shown below is equivalent to this SQL query:
SELECT a.id from AllType a where exists (select b.id from AllType b where b.id = a.id)
Query query = new Query();
query.select("a.id");
query.from("AllType", "a");
AttributeTest test = new AttributeTest();
        
Query existQuery = new Query();
existQuery.select("b.id");
existQuery.from("AllType", "b");
Column cl = new Column();
cl.setAlias("a");
cl.setAttribute("id");
AttributeTest test1 = new AttributeTest();
test1.setAttribute ("b.id");
test1.setValue(cl);
test1.setOperator(AttributeTest.EQUAL);
existQuery.where(test1);
test.setValue(existQuery);
test.setOperator(AttributeTest.EXISTS);
query.where(test);
QueryResultSet qs = SUP101DB.executeQuery(query);