Rules for Where Clauses
Applying the Where Clause to Business ObjectsUse this syntax for where clauses to filter based on business objects: mql expand bus Type_one Object_1 Rev_1 select bus where ' (type == "Type two") && (1 == 1) ' dump Applying the Where clause to RelationshipsSince the where clause works off the rel, you must use ‘to.type’. mql expand bus Type_one Object_1 Rev_1 select rel where ' (to.type == "Type two") && (1 == 1) ' dump Alternatively, you can let expand bus check the object type for you (for more information, see Rules for Where Clauses): mql expand bus Type_one Object_1 Rev_1 type "Type two" select rel where ' (1 == 1) ' dump The first command above is more general, ignoring the direction of the relationship, and the second command only finds Type two’s at the end of relationships pointing from Object_1 to the Type 2 object. If you only want objects connected to Object_1 by the relationship Rel, add ‘rel Rel’: mql expand bus Type_one Object_1 Rev_1 rel Rel select bus where ' (type == "Type two") && (1 == 1) ' dump If you only want to look at the relationship Rel coming from Object_1, add ‘from rel Rel’. This is equivalent to the REL syntax above: mql expand bus Type_one Object_1 Rev_1 from rel Rel select bus where ' (type == "Type two") && (1 == 1) ' dump Using Where Clauses to Filter Connections and Business Objects
To include more extensive filtering, you can also include Where clause criteria in the square brackets of
print bus Drawing My Drawing 0 select from[D*|attribute[RelCount] ~~ "*1"]; The Where clauses are handled exactly as expand bus would handle them. For example, consider a business object Drawing “My Drawing” 0 which has 3 “Drawing of” relationships coming from it, and 2 “Part of Drawing” relationships. On the “Drawing of” relationships, the attribute values for RelCount are 1, 11, and 12. The 3 “Drawing of” relationships point to objects of types Drawing, Sketch and Drawing Markup and these objects have attribute Count values of 1, 11, and 12. The following shows all of this information (and a bit more): print bus Drawing “My Drawing” 0 select from.type from[Drawing of].attribute[RelCount] from[Drawing of].to.type from.to.attribute[Count]; business object Drawing "My Drawing" 0 from[Drawing of].type = Drawing of from[Drawing of].type = Drawing of from[Drawing of].type = Drawing of from[Part of Drawing].type = Part of Drawing from[Part of Drawing].type = Part of Drawing from[Drawing of].attribute[RelCount] = 1 from[Drawing of].attribute[RelCount] = 12 from[Drawing of].attribute[RelCount] = 11 from[Drawing of].to.type = Drawing from[Drawing of].to.type = Drawing Markup from[Drawing of].to.type = Sketch from[Drawing of].to.attribute[Count] = 11 from[Drawing of].to.attribute[Count] = 1 from[Drawing of].to.attribute[Count] = 12 from[Part of Drawing].to.attribute[Count] = 1 from[Part of Drawing].to.attribute[Count] = 1 To get back ONLY the “Drawing of” relations with specified values of RelCount, we could use: print bus Drawing "My Drawing" 0 select from[Drawing of|attribute[RelCount] ~~ "*2"].attribute[RelCount]; business object Drawing "My Drawing" 0 from[Drawing of].attribute[RelCount] = 12 To specify the type of other objects for “Drawing of” relations: print bus Drawing "My Drawing" 0 select from[Drawing of].to[*|type ~~ "*up*"].type; business object Drawing "My Drawing" 0 from[Drawing of].to[Drawing Markup].type = Drawing Markup To specify attribute values on the other object for “Drawing of” relations: print bus Drawing "My Drawing" 0 select from[Drawing of].to[*|attribute[Count] ~~ "*1"].attribute[Count]; business object Drawing "My Drawing" 0 from[Drawing of].to[Drawing Markup].attribute[Count] = 11 from[Drawing of].to[Sketch].attribute[Count] = 1 |