3. Using AccuWork™ : New Query Tab

New Query Tab
You use the New Query tab to create and edit AccuWork queries, and to view and manage query results. Consider using the New Query tab for initial query development—the query and its results are both displayed within the tab, which makes it easy to quickly check query results, modify the query as needed, and then rerun the query. When you are satisfied that the query is performing as expected, you can move it to the Query Browser and save it for use in future AccuRev sessions.
The New Query tab has two panes, each with its own toolbar:
Displaying the New Query Tab
To display the New Query tab, click the New Query button () on the AccuRev main toolbar.
Query Pane
You use the Query pane to can create, modify, and run AccuWork™ queries. When you run a query, AccuRev retrieves the set of AccuWork issue records that satisfy the query from the AccuRev depot and displays them in the Results pane.
The Query pane displays a template you use to build a query by clicking on clauses. The clauses that define the query are displayed as an expandable tree. The tree nodes may contain:
The query name, which is always the top node in the tree. The default name for new queries is New Query N (where N is a unique number).
Simple clauses, such as Assigned To is mary (can appear at any level). Every query has at least one simple clause.
Compound clauses, which start with AND or OR. These clauses can contain any number of other simple or compound clauses.
See Creating a Query for more information on using the tools in the Query pane to create an AccuWork query.
Commands
You can invoke the following commands from the Query pane toolbar.
Run
Runs the query; results are displayed in the Results pane.
Set up Columns
Allows you to specify which columns (AccuWork fields) are displayed in the Results pane for the selected query. You can optionally save selected columns as a default set to be used to display results for any new queries you create. This command is disabled for public queries created by other AccuRev users. See Set up Columns for more information.
Move to Queries
Opens the Query Browser and moves the new query to your list of queries. You must save the query once it has been moved if you want to use it in a new AccuRev session.
(AND) Group
Creates an AND compound clause placeholder as a child of the selection. You must select the query title or another compound clause before this button will be enabled. This command is also available from the context menu.
(OR) Group
Creates an OR compound clause placeholder as a child of the selection. You must select the query title or another compound clause before this button will be enabled. This command is also available from the context menu.
Delete
Deletes the selected clause. This command is also available from the context menu.
Tip: The Delete key on your keyboard also performs the delete action.
Copy
Copies the currently selected query node (the current clause and any subordinate clauses) to the clipboard. See Copying and Pasting Conditions and Clauses on page 66 for more information.
Paste
Pastes the contents of the clipboard into the currently selected query node. See Copying and Pasting Conditions and Clauses on page 66 for more information.
Results Pane
The Results pane displays the issues returned by the query. You can perform the following actions from the Results pane. Commands are available from both the toolbar and context menu unless noted otherwise.
Set Table Size
Allows you to specify the number of issues you want to display on a single page in the Results pane. If the number of issues returned by the query exceeds the number you specify, AccuRev creates additional pages in the Results pane. Available on the toolbar only.
Bulk Update
Allows you to change field values for multiple issues in a single operation. For example, if you assign an Owner to issues, you can use Bulk Update to change the Owner from unassigned to Henry. See Bulk Update for more information.
Sum Columns
Returns the number of issues selected, as well as the sums of all Text fields with numeric-only data and the sums of all Timespan fields. See Sum Columns for more information.
Calculate Columns
Allows you to perform basic mathematical operations (add and subtract, for example) on any two columns with numeric values. Available from the toolbar only. See Calculate Columns for more information.
Show Percentage
Toggles the display of percentage information for the grouped issues. Available from the toolbar only. See Show Percentages for more information.
Group By
Groups the issues shown in the Results pane by the issue field chosen from this drop-down list. Available from the toolbar only. See Group Issues by Field for more information.
Tip: When you group issues, AccuRev enables graphical reporting tools such as pie charts and bar charts. See Charts for more information.
Hide Search Query/Show Search Query
Toggles the visibility of the Query pane. Available from the toolbar only.
Creating a Query
You can use the procedure described in this section to create a query from either the:
The query building tools are the same in both of these interfaces.
To create a query:
1.
In AccuRev, click the New Query button () on the main toolbar.
The New Query tab appears.
Alternative: In the Query Browser, click the New Query button ().
The Query Editor appears.
2.
3.
Click the Click here to add link.
AccuWork displays a template for the clause; use the drop-down list to choose the issue field you want to use to construct your first clause:
Tip: Each time you click Click here to add, AccuWork displays a new Click here to add link, so that one is always available at each level of the query.
4.
Note: Simple clauses at the top level of the query are logically ANDed together by default—that is, an issue in the AccuRev depot must satisfy all of the clauses you specify in order to be returned by the query.
5.
If you created the query in the Query Editor, click the Ok button to save your work. AccuRev runs the query automatically and displays it and its results in the Query Browser.
6.
See Query Results Pane on page 73 to learn about sorting, filtering, and graphing query results.
7.
The query is moved to the Query Browser. It is selected by default.
8.
Click the Save button ().
Working with the Query Builder
The query builder is the tool you use to add and modify clauses in new and existing queries. This section describes editing operations supported by the query builder.
Creating a Simple Clause
Every query consists at least one simple clause. A simple clause has three parts:
<field-name> <comparison-operator> <value>
The point-and-click interface makes creating a simple clause easy. Start by clicking one of the Click here to add links in the query to add placeholders for each part of the clause.
First, select a field name from the list box containing all the field names. When you select the field name, the Query Editor automatically adjusts the available values for the other parts of the clause, based on the values allowed (see Allowed Comparisons and Values) for the selected field.
In the example below, the user has selected the Submitted By field, and is contemplating which comparison operator to choose.
Note that the comparison operators <is in> and <is not in> allow multiple values to be selected. After you select the operator, the options appear in a list box, from which you can make multiple selections. The completed clause contains all the selected values, separated by commas, and the individual values are considered to be combined with an OR.
Therefore, the query displayed below would be read as "Show all issues for which the date submitted is after or equal to April 1, 2009 at 14:52:14, AND the issue state is Complete or Verified."
After creating all three parts of the clause, you can create other simple and compound clauses to finish specifying the search criteria for the query.
Note: Date fields contain an icon that inserts the cur_date variable into the value field. This variable ensures that the clause will refer to the current date when  the query is being accessed.
Creating a Compound Clause
A compound clause combines any number of simple clauses, using the same logical operator: AND or OR. (The NOT operator is not supported.) You can combine both simple and compound clauses.
The query builder automatically creates placeholders for simple clauses, but you must explicitly insert a compound-clause placeholder yourself. To do so, select the query title or an existing AND or OR statement, and click one of  the or buttons. Then, specify the field name, comparison operator, and value for the clause using the Click here to add link under the compound-clause placeholder.
Deleting a Clause
To delete a clause, select it using the selection handle and click the Delete button (). The selection handle is the blue dot that precedes each clause, as shown in the following illustration.
Tip: The Delete key on your keyboard also performs the delete action.
Moving a Clause
To move a clause within a query, click and drag the selection handle, dropping the selected clause on the query title or a compound-clause placeholder. You can move both simple and compound clauses in this way.
Copying and Pasting Conditions and Clauses
When you are building queries, it can be convenient to copy and paste existing AND/OR conditions and individual clauses instead of redefining them manually. The Query Editor copy/paste feature lets you do this.
When you select an AND/OR condition, AccuRev copies the condition and any clauses that have been defined for it to the clipboard. If you select a single clause, only that clause is copied to the clipboard. Items copied in one query definition can be pasted in another.
To copy and paste a query condition or clause:
1.
2.
Click the Copy button () on the toolbar.
Alternative: Right-click the condition or clause and choose Copy from the context menu.
3.
4.
Click the Paste button () on the toolbar.
Alternative: Right-click the target for the paste operation and choose Paste from the context menu.
5.
Editing a Query
To edit an existing query:
1.
2.
Click the Edit Query button ().
The query appears in the Query Editor, as shown in the following illustration.
Generally speaking, you can perform as editing operations any operation you perform to build the query. For example, you can:
See Working with the Query Builder for more information.
Note: You cannot rename a query using the Edit operation. See Renaming a Query for more information.
Renaming a Query
To edit an existing query:
1.
2.
Click the Rename Query button ().
The Rename Query dialog box appears.
3.
The query is renamed and remains selected in the Query Browser.
4.
Click the Save button ().
The query is saved with the new name.
Allowed Comparisons and Values
The following table shows all the AccuWork data types, along with the corresponding choices for the <comparison-operator> and <value> parts of a simple clause.
The contains and does not contain operators perform a simple case-insensitive substring search, with no pattern matching.
The matches and does not match operators perform case-insensitive pattern matching, using these wild cards:
*  matches 0 or more characters
?  matches any 1 character
[aekz]  matches a, e, k, or z
[a-e]  matches a, b, c, d, or e (do not mix uppercase and lowercase here)
{one,two,seven}  matches one, two, or seven
\ or /  Matches any directory-separator character, even if it is the "wrong one" for the client machine. For example, src/do_*.java matches src\do_something.java on a Windows client.
Rls 4* matches Rls 4 and Rls 4.01, but not Rls 4.2 or Rls 5
Rls [2-5]* matches Rls 2, Rls3.04, and Rls 5.3, but not Rls 1.02
the -? option matches the -X option and the -4 option, but not the -Op option
cop{y,ies} matches copy and copies, but not copy(s)
Any character string. This string is compared to the Names of an issue record's attachments.
An integer, identifying a particular AccuWork issue record (Issue field) or a particular AccuRev transaction (Transaction field).

Borland