SELECT

Purpose

Retrieves qualified records for the specified incident or problem.

Syntax and Description

select {*|[field1, [field2, ...]} FROM {incident|problem}
  [WHERE predicate_string]
  [ORDER BY field1 [, field2, ...] [ASC|DSC|DESC]]
  [GROUP BY field1 [, field2, ...]]
  [HAVING having_predicate_string]

Table 17-10 Flags for the SELECT command

Flag Description

field1, field2, ...

Lists the fields to retrieve. If * is specified, then all fields are retrieved.

incident|problem

Indicates whether to query incidents or problems.

WHERE "predicate_string"

Uses a SQL-like predicate string to show only the incident or problem for which the predicate is true. The predicate string must be enclosed in double quotation marks.

Table 17-16 lists the fields that can be used in the predicate string incidents.

Table 17-20 lists the fields that can be used in the predicate string for problems.

ORDER BY field1, field2, ... [ASC|DSC|DESC]

Show results sorted by field in the given order, as well as in ascending (ASC) and descending order (DSC or DESC). When the ORDER BY clause is specified, results are shown in ascending order by default.

GROUP BY field1, field2, ...

Show results grouped by the specified fields.

The GROUP BY flag groups rows but does not guarantee the order of the result set. To order the groupings, use the ORDER BY flag.

HAVING "having_predicate_string"

Restrict the groups of returned rows to those groups for which the having predicate is true. The HAVING flag must be used in combination with the GROUP BY flag.


Note:

The WHERE, ORDER BY, GROUP BY, and HAVING flags are similar to the clauses with the same names in a SELECT SQL statement. See Oracle Database SQL Language Reference for more information about the clauses in a SELECT SQL statement.

Restrictions

The following restrictions apply when you use the SELECT command:

  • The command cannot join more than two tables.

  • The command cannot use table aliases.

  • The command can use only a limited set of functions, which are listed in this section.

  • The command cannot use column wildcard ("*") when joining tables or when using the GROUP BY clause.

  • Statements must be on a single line.

  • Statement cannot have subqueries.

  • Statement cannot have a WITH clause.

  • A limited set of pseudocolumns are allowed. For example, ROWNUM is allowed, but ROWID is not allowed.

Examples

This example retrieves the incident_id and create_time for incidents with an incident_id greater than 1:

select incident_id, create_time from incident where incident_id > 1

The following is sample output for this query:

INCIDENT_ID          CREATE_TIME                              
-------------------- ---------------------------------------- 
4801                 2011-05-27 10:10:26.541656 -07:00       
4802                 2011-05-27 10:11:02.456066 -07:00       
4803                 2011-05-27 10:11:04.759654 -07:00       

This example retrieves the problem_id and first_incident for each problem with a problem_key that includes 600:

select problem_id, first_incident from problem where problem­_key like '%600%'

The following is sample output for this query:

PROBLEM_ID           FIRST_INCIDENT       
-------------------- -------------------- 
1                    4801                
2                    4802                
3                    4803                

Functions

This section describes functions that you can use with the SELECT command.

The purpose and syntax of these functions are similar to the corresponding SQL functions, but there are some differences. This section notes the differences between the functions used with the ADRCI utility and the SQL functions.

The following restrictions apply to all of the functions:

  • The expressions must be simple expressions. See Oracle Database SQL Language Reference for information about simple expressions.

  • You cannot combine function calls. For example, the following combination of function calls is not supported:

    sum(length(column_name))
    
  • No functions are overloaded.

  • All function arguments are mandatory.

  • The functions cannot be used with other ADRCI Utility commands.


Table 17-11 ADRCI Utility Functions for the SELECT Command

Function Description

AVG

Returns the average value of an expression.

CONCAT

Returns the concatenation of two character strings.

COUNT

Returns the number of rows returned by the query.

DECODE

Compares an expression to each search value one by one.

LENGTH

Returns the length of a character string using as defined by the input character set.

MAX

Returns the maximum value of an expression.

MIN

Returns the minimum value of an expression

NVL

Replaces null (returned as a blank) with character data in the results of a query.

REGEXP_LIKE

Returns rows that match a specified pattern in a specified regular expression.

SUBSTR

Returns a portion of character data.

SUM

Returns the sum of values of an expression.

TIMESTAMP_TO_CHAR

Converts a value of TIMESTAMP data type to a value of VARCHAR2 data type in a specified format.

TOLOWER

Returns character data, with all letters lowercase.

TOUPPER

Returns character data, with all letters uppercase.