Basic predicate

A basic predicate compares two values or compares a set of values with another set of values.

This statement can be embedded only in a COBOL application program.

Read syntax diagramSkip visual syntax diagramcolumn=<>!=<><=>= literal
column
Read syntax diagramSkip visual syntax diagramtable-name.column-name1
Notes:
  • 1 You can have the same column name in multiple tables, but if the table is not qualified, each table must be searched for the column.

This statement is supported only for Java™ application programs.

Read syntax diagramSkip visual syntax diagramcolumnalias=<>!=<><=>= literal
column
Read syntax diagramSkip visual syntax diagramschema-name.table-name.column-name1
Notes:
  • 1 You can have the same column name in multiple tables, but if the table is not qualified, each table must be searched for the column.

The result of the predicate depends on the operator, as in the following two cases:

  • If the operator is =, the result of the predicate is:
    • True if all pairs of corresponding value expressions evaluate to true.
    • False if any one pair of corresponding value expressions evaluates to false.
  • If the operator is <>, the result of the predicate (x1,x2,...,xn) <> (y1,y2,...,yn) is:
    • True, if and only if xi=yi evaluates to false for some value of i. (that is, there is at least one pair of non-null values, xi and yi, that are not equal to each other).
    • False, if and only if xi=yi evaluates to true for every value of i. (that is, (x1,x2,...,xn)=(y1,y2,...,yn) is true).
Table 1. For values x and y
Predicate Is true only if ...
x = y x is equal to y
x <> y x is not equal to y
x < y x is less than y
x > y x is greater than y
x <= y x is less than or equal to y
x >= y x is greater than or equal to y

Examples for values x and y:

   HOSPCODE = '528671'
   XINTEGER < 20000
   HOSPNAME <> :VAR1

Example: List the hospital code and hospital name from the HOSPITAL segment where the hospital code is H5140070000H.

 SELECT HOSPCODE, HOSPNAME
    FROM PCB01.HOSPITAL
    WHERE HOSPCODE = 'H5140070000H'