COMPARE function

The COMPARE function performs an exact byte-by-byte comparison of two large objects for a given length at given offsets.

The function returns:
  • Zero if both large objects are exactly the same for the specified length for the specified offsets
  • Non-zero if the objects are not the same
  • Null if amount, offset_1, or offset_2 are less than zero.

The large objects being compared must be the same data type.

Syntax

COMPARE(lob_1, lob_2 [ ,amount [ ,offset_1 [ ,offset_2 ] ] ] )

Parameters

lob_1
An input argument of type BLOB(10M) or CLOB(10M) that specifies the large object locator of the first large object to be compared. Must be the same data type as lob_2.
lob_2
An input argument of type BLOB(10M) or CLOB(10M) that specifies the large object locator of the second large object to be compared. Must be the same data type as lob_1.
amount
An optional input argument of type INTEGER. If the data type of the large objects is BLOB, then the comparison is made for amount bytes. If the data type of the large objects is CLOB, then the comparison is made for amount characters. The default is the maximum size of a large object.
offset_1
An optional input argument of type INTEGER that specifies the position within the first large object to begin the comparison. The first byte (or character) is offset 1. The default is 1.
offset_2
An optional input argument of type INTEGER that specifies the position within the second large object to begin the comparison. The first byte (or character) is offset 1. The default is 1.