The query language is used to formulate queries on VOBs. It includes logical operators similar to those in the C programming language. A query searches one or more VOBs and returns the names of objects: versions, branches, and/or elements. A query may return a single object, many objects, or no objects at all.
A query primitive evaluates to TRUE or FALSE. A TRUE value selects an object, such as an element, branch, or version; a FALSE value excludes it.
A query must be enclosed in quotes if it includes spaces. You may also need to enclose a query in quotes to prevent shell-level interpretation of characters such as ( (open parenthesis). Quoting parentheses in config specs is not required.
You can use a query in a version selector in these contexts:
describe, merge, mkattr, mkbranch, mklabel, rmattr, rmlabel, rmver
A query in a version selector must be enclosed in braces ( {} ).
When a query is applied to a single branch, ClearCase and ClearCase LT select the most recent version on that branch that satisfies the query. For example:
Using a query without a branch pathname causes an element's entire version tree to be searched. If the query returns a single version, the version-selection operation succeeds; the operation fails if the query returns no version (not found) or returns more than one version (ambiguous). For example:
The query language includes these primitives:
attribute-type-name comparison-operator value
comparison-operator is one of the following:
Examples:
BugNum==4053
BugNum>=4000
Status!="tested"
This primitive is TRUE if the object itself has an attribute of that type and the value comparison is true. To test whether an object or its subobjects has a particular attribute (for example, an element or its branches and versions), use the attr_sub primitive.
Note: If no attribute named BugNum has been attached to an object, then !BugNum==671 is TRUE, but BugNum!=671 is FALSE. The second query would be true if an attribute of type BugNum existed, but had a different value.
date.time | date | time |now where:
Specify the time in 24-hour format, relative to the local time zone. If you omit the time, the default value is 00:00:00. If you omit the date, the default is today. If you omit the century, year, or a specific date, the most recent one is used. Specify UTC if you want to resolve the time to the same moment in time regardless of time zone. Use the plus (+) or minus (-) operator to specify a positive or negative offset to the UTC time. If you specify UTC without hour or minute offsets, Greenwich Mean Time (GMT) is used. (Dates before January 1, 1970 Universal Coordinated Time (UTC) are invalid.)
Note that in this context, version-selector cannot itself contain a query. For example, version(REL1) is valid, but version(lbtype(REL1)) is not.
Primitives can be combined into expressions with logical operators. An expression can take any of these forms, where query is a primitive or another expression:
query || query | Logical OR |
query && query | Logical AND |
! query | Logical NOT |
( query ) | Grouping to override precedence |
The precedence and associativity of the operators for attribute comparisons and formation of logical expressions are the same as in the C programming language:
The UNIX examples in this section are written for use in csh. If you use another shell, you may need to use different quoting and escaping conventions.
The Windows examples that include wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you may need to change the wildcards and quoting to make your command interpreter process the command appropriately.
In cleartool single-command mode, cmd-context represents the UNIX shell or Windows command interpreter prompt, followed by the cleartool command. In cleartool interactive mode, cmd-context represents the interactive cleartool prompt.
UNIX:
% cleartool mklabel -ver '{lbtype(REL5)}' REL6 test.c
Created label "REL6" on "test.c" version "/main/4".
Windows:
UNIX:
% mkattr -ver '{created_since(yesterday.13:00)&&created_by(asd)}' QAed \"No\" test.c
Created attribute "QAed" on "test.c@@/main/5".
Windows:
UNIX:
% cleartool find . -branch 'brtype(rel2_bugfix)&&trtype(mail_all)' -print
./util.c@@/main/rel2_bugfix
Windows:
Copyright© 2003 Rational Software. All Rights Reserved.