Previous Topic: SELECT Selection CriteriaNext Topic: FIND / GET Selection Criteria


SELECT Comparison-Expression

Comparison-Expression is used in the SELECT WHERE criteria clause and in the SELECT HAVING criteria clause.

Access mode: The syntax below is invalid when the access switch is set to IDMS.

Syntax:

►►─┬─ expression ─┬─┬───────┬─ IN ─┬─ data-value ─────────────┬───┬─────────┬─►◄
   │              │ └─ NOT ─┘      │     ┌────── , ─────┐     │   │         │
   │              │                └─ ( ─▼─ data-value ─┴─ ) ─┘   │         │
   │              ├─┬───────┬─ LIKe ─┬─ data-value ─────────────┬─┤         │
   │              │ └─ NOT ─┘        │     ┌────── , ─────┐     │ │         │
   │              │                  └─ ( ─▼─ data-value ─┴─ ) ─┘ │         │
   │              ├─┬─ MATches ──┬─┬─ character-string ─┬─────────┤         │
   │              │ └─ CONtains ─┘ └─ mask-value ───────┘         │         │
   │              └─┬─ = ──┬─ expression ─────────────────────────┘         │
   │                ├─ <> ─┤                                                │
   │                ├─ > ──┤                                                │
   │                ├─ < ──┤                                                │
   │                ├─ >= ─┤                                                │
   │                └─ <= ─┘                                                │
   ├─┬─ field-reference ─────┬┬─┬ = ─┬─ data-value ─┬─ TO ───┬─ data-value ┬┤
   │ └─ function-expression ─┘│ └ <> ┘              └─ THRU ─┘             ││
   │                          └─┬─────┬─ BETween data-value AND data-value ┘│
   │                            └ NOT ┘                                     │
   │                                                                        │
   └─ set-name ─┬────────────────────┬─┬────────────────────┬───────────────┘
                ├─ ,record-name ─────┤ ├─ ,record-name ─────┤
                └─ ,alt-source-name ─┘ └─ ,alt-source-name ─┘

Syntax rules:

expression

Specifies a series of constants or variables separated by operators that yields a single value.

IN data-value

Compares an expression to a data value or a list of data values:

LIKE data-value

Searches the expression for a data value.

Object String

Data Value

Example of Syntax

Example of True comparison

Underscore (┘)

Any single character

NAME LIKE 'S┘┘'

True if NAME is exactly 3 characters long and the first character is S

Percent sign (%)

Any sequence of zero or more characters

NAME LIKE '%C┘┘'

True if NAME is 3 or more characters long AND the third from last character is C

Single alphanumeric character

Exact match to that alphanumeric character

NAME LIKE 'MAC'

True if NAME is MAC

Escape character + underscore (┘)

Exact match to the underscore (┘)

PARTNUM LIKE '*┘115' ESCAPE '*'1

True if PARTNUM is '┘115'

Escape character + percent sign (%)

Exact match to the percent sign (%)

PARTNUM LIKE '*%15' ESCAPE '*'1

True if PARTNUM is '%15'

Escape character alone

Exact match to the escape character

PARTNUM LIKE '****' ESCAPE '*' (note below)

True if PARTNUM is **

The escape character can be any single alphanumeric character and is set by specifying ESCAPE 'escape-character' in your SELECT statement.

MATCHES/CONTAINS

Specifies search conditions as follows:

= <> > < >= <=

Specifies the comparison operator:

expression

Specifies the expression the named condition is compared to.

Note: See the expansion of Expression, later in this chapter.

field-reference

Identifies a field.

Note: For more information, see the expansion of FIND / GET and COMPUTE Field-Reference Clause, later in this chapter.

function-expression

An expression containing a built-in function. Note that built-in functions can be nested.

= <> data-value

Data-value represents data values to which the named field is compared. Specifies that a column expression or column name equals (=) or doesn't equal (<>) the specified data value.

TO/THRU data-value

Specifies a range of data values to which the named field is compared. THRU indicates an inclusive range. TO indicates an exclusive range.

BETWEEN data-value and data-value

Specifies a range of data values to which the named field is compared. BETWEEN indicates that the named field meets the requirements inclusive of the boundaries specified by data-value AND data-value. NOT BETWEEN indicates that the named field doesn't meet the requirements inclusive of the boundaries specified by data-value AND data-value.

set-name

Identifies a set relationship. This sub-clause is valid in the WHERE clause only. Set-name is required.

record-name

Is the name of either the owner or member record of the set. Either the owner or member record can be specified or omitted.

alt-source-name

Specifies an alternative name used to identify records with the same name. Alt-source-name is a 1- to 8-character alphanumeric literal.

For more information:

Coding Considerations