Start of change

COMPARE_MIRROR_VERSION scalar function

The COMPARE_MIRROR_VERSION scalar function returns an indication whether the first version identifier is less than or equal to the second version identifier specified on the function.

This indication can be used to quickly indicate if the first version identifier matches or is covered by the second version identifier. Version identifiers in the form xxx.yyy.zzz first compare the xxx values. If they are equal, then the yyy values are compared. If the values are still equal, the zzz values are compared. Both version-identifier1 and version-identifier2 can be specified using only one or two parts of the version identifier. For example, xxx.yyy or xxx. Any omitted parts of a version identifier use an implicit value of zero for comparisons.

Authorization: For the authority needed to use this function, see Authorization.

Read syntax diagramSkip visual syntax diagramCOMPARE_MIRROR_VERSION( VERSION_IDENTIFIER1 =>  version-identifier1 ,VERSION_IDENTIFIER2 =>  version-identifier2 )
The schema is QSYS2.
version-identifier1

A character or graphic string expression that identifies the first version identifier for the compare. version-identifier1 must be in the form xxx.yyy.zzz with each piece of the version containing the digits 0-9. Each segment of the version can contain one to three digits. If less than three digits are used, the value is logically padded on the left with leading zeros.

version-identifier2

A character or graphic string expression that identifies the second version identifier for the compare. version-identifier2 must be in the form xxx.yyy.zzz with each piece of the version containing the digits 0-9. Each segment of the version can contain one to three digits. If less than three digits are used, the value is logically padded on the left with leading zeros.

The result of the function is VARCHAR(3).

The result is one of the following values:
NO
Either the version-identifier1 parameter is greater than the version-identifier2 parameter, or the version identifiers could not be compared.
YES
The version-identifier1 parameter is less than or equal to the version-identifier2 parameter specified on the function.

Examples

  • A compare where both versions are lexically identical returns a value of YES.
    VALUES QSYS2.COMPARE_MIRROR_VERSION(VERSION_IDENTIFIER1 => '1.3', 
                                        VERSION_IDENTIFIER2 => '1.3.0');
  • Performing a compare where the version number 1.3.1 for version-identifier2 is greater than the version number 1.3.0 for version-identifier1 returns a value of YES.
    VALUES QSYS2.COMPARE_MIRROR_VERSION(VERSION_IDENTIFIER1 => '1.3.0', 
                                        VERSION_IDENTIFIER2 => '1.3.1');
  • Performing a compare where the version number 1.3.1 for version-identifier1 is greater than the version number 1.3.0 for version-identifier2 returns a value of NO.
    VALUES QSYS2.COMPARE_MIRROR_VERSION(VERSION_IDENTIFIER1 => '1.3.1', 
                                        VERSION_IDENTIFIER2 => '1.3.0');
  • Performing a compare where either version number parameter contains the NULL value returns a value of NO.
    VALUES QSYS2.COMPARE_MIRROR_VERSION(VERSION_IDENTIFIER1 => NULL, 
                                        VERSION_IDENTIFIER2 => '1.3.1');
  • When an invalid version is specified for either version identifier parameter, then a CPDC91D message is sent to the job log and an SQLSTATE of 42616 (parameter value not valid) is returned.
    VALUES QSYS2.COMPARE_MIRROR_VERSION(VERSION_IDENTIFIER1 => 'NOT VALID', 
                                        VERSION_IDENTIFIER2 => '1.3.1');
End of change