2.7.4 Rules common to predicates

  1. For types of data that can be compared, see 1.2.2 Data types that can be converted (assigned or compared). However, if a character string literal is specified as an object of comparison of national character data, the character string literal is treated as a national character literal. If a character string literal is treated as a national character string literal, the character data receives a length check only, and the character code is not checked.
  2. Character data cannot be compared if the character sets are different. If the conditions in the following table are met, however, the character set can be converted to a character set for which comparison is supported, allowing comparisons to be performed.

    Table 2-1 Conditions for being able to compare different character sets (for EBCDIK and the default character set (SJIS))

    EBCDIK value expressionDefault character set (SJIS) value expression
    Character string literalEmbedded variable, ? parameterCharacter string literal, embedded variable, ? parameter
    Character string literal------
    Embedded variable, ? parameterNNN
    Character string literal, embedded variable, ? parameterYYN
    Legend:
    Y: Converted to an EBCDIK character code and then compared.
    N: Cannot be compared.
    --: Not supported.

    Table 2-2 Conditions for being able to compare different character sets (for UTF-16 and default character set (UTF-8))

    UTF-16 value expressionDefault character set (UTF-8) value expression#
    Character string literalEmbedded variable, ? parameterCharacter string literal, embedded variable, ? parameter
    Character string literal------
    Embedded variable, ? parameterYesNYes
    Character string literal, embedded variable, ? parameterYYN
    #
    Includes mixed character data.
    Legend:
    Yes: Converted to UTF-16 character encoding and then compared.
    Y: Converted to UTF-8 character encoding and then compared.
    N: Cannot be compared.
    --: Not supported.
  3. Before comparing two fixed-length data items or a fixed-length data item and variable-length data item of different lengths, the shorter data item is right-filled with the character set's space character to make the strings the same length.
  4. When comparing two variable-length character data items of different lengths, HiRDB performs the comparison from the left, for a length equal to the length of the shorter data item. If the results are equal, HiRDB further compares the character string lengths.
  5. When comparing two numeric data items of different data types, HiRDB performs the comparison by using the data type of the wider range. Different numeric data types have the following range widths:
    FLOAT > SMALLFLT > DECIMAL > INTEGER > SMALLINT
    If one of the items to be compared with is the SMALLFLT, it is compared as a FLOAT type irrespective of the width of its range.
  6. When comparing two time stamp data items of different fractional second precisions, HiRDB extends the fractional precision of the lower precision item to match the precision of the higher precision item, and zero-fills the extended fractional second part.
  7. When comparing two BINARY type items of different data lengths, HiRDB performs the comparison from the left, for a length equal to the length of the shorter data item. If the results are equal, HiRDB further compares the data lengths.