The COMPARE function compares two large objects (LOB)s in full or in part.
Syntax
DBMS_LOB.COMPARE (
lob_1 IN BLOB,
lob_2 IN BLOB,
amount IN INTEGER := DBMS_LOB.LOBMAXSIZE,
offset_1 IN INTEGER := 1,
offset_2 IN INTEGER := 1)
RETURN INTEGER;
DBMS_LOB.COMPARE (
lob_1 IN CLOB CHARACTER SET ANY_CS,
lob_2 IN CLOB CHARACTER SET lob_1%CHARSET,
amount IN INTEGER := DBMS_LOB.LOBMAXSIZE,
offset_1 IN INTEGER := 1,
offset_2 IN INTEGER := 1)
RETURN INTEGER;
Parameters
| Parameter | Description |
|---|---|
| lob_1 | The locator of the first LOB for comparison. |
| lob_2 | The locator of the second LOB for comparison. |
| amount | The amount of data to compare. The value is in bytes for binary LOBs (BLOBs) and in characters for character LOBs (CLOBs). |
| offset_1 | The offset, with 1 as the origin, on the first LOB for comparison. The value is in bytes or characters. |
| offset_2 | The offset, with 1 as the origin, on the second LOB for comparison. The value is in bytes or characters. |
Return values
The return value is
INTEGER: The value of0indicates a successful comparison, whereas any other integer value indicates a failed comparison.If any of the
amount,offset_1oroffset_2parameters is not a valid LOB offset value, the return value isNULL. The valid offset value ranges from 1 to the value ofLOBMAXSIZE.
Usage notes
The COMPARE function compares only LOBs of the same data type. For example, it compares a BLOB only with another BLOB, and a CLOB only with another CLOB.
If the two values are fully consistent with each other in the range specified by the
offsetandamountparameters,COMPAREreturns0.COMPAREreturns-1if the first CLOB is smaller than the second, and1if the first CLOB is greater than the second.For a CLOB with a fixed width of n bytes, if you specify that the value of the
amountparameter ofCOMPAREis greater thanDBMS_LOB.LOBMAXSIZE/n, the matching range of COMPARE isDBMS_LOB.LOBMAXSIZE/n,Max(length (clob1), orlength(clob2), whichever is smaller.