[TOC] [Prev]
[Next]
Using the Query Bar
Use the query bar, as shown in the figure below, when you want to define
a query that does more than simply find ARs with fields that match an example.
The query bar lets you define more complex logical statements. For example,
you may want to match one field or another. You also use the query bar
whenever you want to use a Status History field item in your query. Remember
that the criteria you enter in the query bar are used in conjunction with
any criteria defined in the query-by-example section of the window.

Figure: Query Bar
You can define a query statement in the query bar by using any of the
following techniques:
- Type information in the Query field.
- Click on a field label in the query-by-example area to add a field.
- Select a field label or a keyword from the Field List dialog box to
add a field, a status history item, or a keyword.
- Select an operator from the query bar palette to add an operator.
Note: You can hide the query
bar from view when it is not used. To hide (or display) the query bar,
display the query preferences. See Setting
User Preferences.
You must follow certain formatting conventions in constructing the query
statement. The sections that follow describe these conventions as well
as the logical and arithmetic operators that you can use. You can also
use the Edit menu operations (Cut, Copy, Paste, Clear, and Copy All) in
the Query Bar.
This section contains information about the following topics:
Entering information in the query bar
- Add a field name to the query bar using any of the following methods:
- Select the Fields button on the query bar to display the Field List
dialog box that lists all of the fields on the schema. You can then select
any listed field name. You can also select a Status History field item
or keyword from the Field List dialog box.
- Click on a field label in the query-by-example area to add it to the
query bar within single quotes.
- Type the field name, enclosed in single quotes, in the query bar. (Field
labels that use spaces or special characters must be enclosed in single
quotes. You may want to establish the habit of using the single quotes
even when they are not specifically required for the field specification.)
For example, if you select the field name Ticket Status, you see: 'Ticket
Status'
Type an operator or select the appropriate operator from the palette
in the query bar.
The operator is added to the query bar.
For example, if you select (or type) the equals sign (=), you see: 'Ticket
Status' =
- Select another field or type a field value.
When typing in a field value, non-numeric values must be enclosed in
double quotes. These values are case and space-sensitive.
For example, you could enter Open in the query bar. For example: 'Ticket
Status' = ''Open''
- Continue adding operators, field names, and field values until you
have completed the query statement. You can put spaces between operators,
field names, and field values, but you don't have to.
For example: 'Ticket Status' = ''Open'' OR 'Ticket
Status' = ''Escalated''
- When you are ready to perform the query, select the query operation
that you want from the Query menu. The query operations are described in
the section Query Operations later
in this chapter.
[Top]
Query Bar Format and Syntax
You must follow a set of formatting conventions when you build a query
in the query bar. You can use the relational operators and wild card symbols
shown in Relational Operators Used in the Query
Window and Wild Card Symbols
in the query bar. You can also use the operators shown in Operators
Used in the Query Bar.
The preceding example, 'Ticket Status'=''Open'', finds only the ARs
with a status of "Open". By itself, this may be the lowest common
denominator in your search but it may also provide you with far too many
matches. To avoid the frustration of going through all of them, you can
refine your search by using the query bar operators. Refining your query
criteria helps you narrow down the number of ARs you need to deal with
when searching for a specific answer.
[Top]
Using Operators in the Query Bar
You can use the operators shown in the table below in the query bar
in addition to the wild card characters described earlier in Using
Wild Card Symbols.
Table: Operators Used in the Query Bar
| Operator |
Action |
|
AND
&&
|
Logical AND of the result of two conditions (the result is true only
if both conditions are true).
For example, 'Status'=''New'' AND 'Assigned-to'=''Andy''
would find all new ARs assigned to Andy. You can use the symbols &&
instead of the word AND.
|
|
OR
||
|
Logical OR of the result of two conditions (the result is true if either
condition is true).
For example, 'Status'=''New'' OR 'Assigned-to'=''Andy''
would find all new ARs and all ARs assigned to Andy (no matter what their
status). You can use the symbol || (two vertical lines) instead of the
word OR.
|
|
NOT
!
|
Negates the condition that follows (if the condition is false, the
result is true).
For example, NOT 'Status'=''New''
would find all ARs that are not new. You can use the symbol ! (exclamation
point) instead of the word NOT.
|
|
LIKE
|
Performs a pattern search.
For example, 'Submitter' LIKE ''Bob%ton''
would find all ARs with a submitter name that begins with the letters "Bob"
and ends with the letters "ton" - such as Bob Compton and Bobby
Fenton. The LIKE operator is useful only with character and diary type
fields. Note, using square brackets and the LIKE operator works for flat
files, Sybase, and Ingres. Using square brackets and the LIKE operator
does not work with Oracle or Informix. Refer to the Action Request System
Installation Guide for more information.
|
|
+
|
Adds two integer or real values.
Adds an integer interval to a time value.
Concatenates two character strings.
For example, 'Create-date' > $DATE$ + (28800)
would find all ARs that were created after 8:00 am today. (28800 is the
number of seconds in 8 hours.)
|
|
-
|
Subtracts two integer or real values.
Subtracts two time values (resulting in an integer).
Subtracts an integer interval from a time value.
For example, 'Create-date' > $DATE$ - (604800)
would find all ARs that were created within the past week. (604800 is the
number of seconds in one week.) This is useful to include in a custom report
that you run weekly that creates a report of all ARs created in the past
week.
|
|
*
|
Multiplies two integer or real values.
For example, 'Quantity' * 'Price' > 50
finds all ARs where the contents of the Quantity field multiplied by the
contents of the Price field is over 50.
|
|
/
|
Divides two integer or real values.
For example, 'Total Expenses' / 'Total Income'
> 1 would find all ARs where the total amount spent
for expenses equaled the total amount brought in as income.
|
|
%
|
Modulo of two integer values (the remainder of a division of the values).
Since a percent sign is also a valid wild card symbol, the context when
using a percent sign determines how it is interpreted.
For example, 'ID' % 2 = 1 finds
all ARs with an odd number in the ID field.
|
|
<
|
Matches contents that are less than the value.
For example, 'Create-date' < ($DATE$ - 86400)
would find all ARs created more than 24 hours ago. (86400 is the number
of seconds in 24 hours.)
|
|
>
|
Matches contents that are greater than the value.
For example, 'Create-date' > "06/10/94
00:00:00" would find all ARs with Create-dates that
are newer than at midnight June 10, 1994.
|
|
!=
|
Matches contents that are not equal to the value.
For example, 'Status' != "Closed"
finds all ARs that aren't closed.
|
|
<=
|
Matches contents that are less than or equal to the value.
For example, 'Salary'<= 10000
would find all ARs where the contents of the Salary field is less than
or equal to 10000.
|
|
>=
|
Matches contents that are greater than or equal to the value.
For example, 'Create-date' >= "10/31/94"
would find all ARs with Create-dates equal to or more recent than October
31, 1994.
|
|
=
|
Matches contents that are exactly equal to the value. For example,
'Status' = 0 would find all ARs with
a status value equal to the first selection value. |
[Top]
Operator precedence
When you use multiple operators in constructing qualification criteria,
they are executed in the following order of precedence (in the following
order that they appear within the qualification):
- ( )
- !, NOT, - (unary minus)
- *, /, %
- +, -
- <, <=, >, >=, =, !=
- && (AND)
- || (OR) If the same operator is included more than once in the same
qualification (or two operators of the same precedence are used in the
same qualification), the first time each operator is found going from left
to right it is per
[Top]
Query bar statement conventions
Use the following conventions to construct a query statement in the
query bar.
Fields
Enclose field labels in single quotes. Single quotes are automatically
added when you select fields from the Field List dialog box or when you
select fields by clicking on them in the query-by-example part of the window.
For example: 'Short Description'
You can also reference fields by using their internal field ID. If you
use the ID, you must enclose it in single quotes. For more information
about the field ID, see the Action Request System Administrator's Guide.
Note: If a field name contains
a single quote, you must double the embedded single quote (that is, use
two single quotes). For example, if the field is named "Submitter's
Phone Number" you need to enter it as 'Submitter''s Phone Number'.
This is done for you automatically if you select the field name from the
Field List dialog box or by selecting the label in the query-by-example
section.
Values
Enclose non-numeric values (including time and selection values) in
double quotes.
For example: ''07/01/92''
You can use the special value $NULL$ (without quotes) to query for ARs
that have no value in a field. For example, to query for ARs that
have not been assigned (fields with no value in the Assigned-to field),
you would enter: 'Assigned-to' = $NULL$.
Selection field values can either be specified as the text value in
quotes or the numeric value or index not in quotes. For instance, if you
have a Status field with the following radio buttons: Open, Fixed, and
Verified, to specify the value of Open you can either enter Open or 0 since
Open is the first selection value in the selection field.
Status
Status History field items must have the following information History
and format enclosed within single quotes:
- The name or ID of the Status History field (followed by a period).
- The name or index of the status value you want to match (followed by
a period).
- The keyword USER (for the user who changed the AR to that status) or
TIME (for the time last changed to that status).
For example: 'Status-History.Fixed.TIME' < ''07/01/92''
or, using field IDs,: '15.3.1' < ''07/01/92''
The correct syntax is entered for you automatically if you choose the
Status History field item from the Field List dialog box.
[Top]
Examples of query statements
- Find all ARs that were submitted by someone other than the current
user. The example uses the not equal to operator (!=) to find instances
where the value in the Submitter field is not equal to the currently logged
in user. Note the use of the $USER$ keyword.
'Submitter' != $USER$
Find all ARs that were submitted after 10:00 am on the current day.
The example uses the greater than operator (>) to find ARs where the
value of the Create-date field is greater than the current day at 10:00.
'Create-date' > ''10:00:00''
Find all ARs that have been submitted for any problem having to do
with printing. The example uses the LIKE operator to perform a pattern
search that finds ARs with the word "Print" or "print"
anywhere in the Submitted Problem Type field. The example works for flat
files, Sybase, and Ingres. Using square brackets and the LIKE operator
does not work with Oracle or Informix. Refer to Database Considerations
in Chapter 4 of the Action Request System Installation Guide for more
information.
'Submitted Problem Type' LIKE ''%[Pp]rint%''
Find all ARs with a Status of Released. Notice the spaces after the
word "Status" in the field specification. In this case, the spaces
exist in the field label as defined on the schema being used. Because the
AR System recognizes spaces that exist, the spaces must also be included
in any qualification statement for that field. If you use the Field List
dialog box by selecting the Fields button on the qualification bar, the
spaces (and single quotation marks) are added for you automatically.
'Status ' = ''Released''
[Top] [TOC] [Prev]
[Next]
support@remedy.com
Copyright © 1996, Remedy Corporation. All rights reserved.