BUFFER-COMPARE statement
- Last Updated: April 23, 2026
- 4 minute read
- OpenEdge
- Version 12.8
- Documentation
Performs a bulk comparison of two records (source and target) by comparing
source and target fields of the same name for equality and storing the result in a field.
You can specify a list of fields to exclude, or a list of fields to include. You can also
specify WHEN...THEN phrases. For all such phrases you
specify, the AVM evaluates the WHEN portion, and if it evaluates to TRUE,
the AVM executes the THEN portion.
Syntax
|
- source
- The source database table, buffer, temp-table, or work table.
- EXCEPT field
- A list of source fields to exclude from the bulk compare.
- USING field
- A list of source fields to include in the bulk compare. The
USINGoption is a positive version of theEXCEPToption. - TO target
- The target database table, buffer, temp-table, or work table.
- CASE-SENSITIVE
- Directs the AVM to perform a case-sensitive comparison.
- BINARY
- Directs the AVM to perform a binary comparison.
- SAVE RESULT IN result-field
- A variable or field to contain the result of the comparison. The
variable or field must be CHARACTER or LOGICAL.
If result-field is CHARACTER, the result is a comma-separated list of fields that failed the comparison, sorted in ascending order.
If result-field is LOGICAL, the result is YES if all fields are equal, or NO if any fields are unequal. In either case,
BUFFER-COMPAREstops comparing when it encounters the first inequality. - EXPLICIT COMPARES
- Opens a block of
WHENoptions. If you open the block, you must close it withEND COMPARES. - WHEN field
- Any data field in the source.
BUFFER-COMPAREremoves this field from aUSINGlist or adds this field to anEXCEPTlist. This removes the field from the bulk compare and from result-field. - compare-operator
- Represents one of the following:
LT,LE,GT,GE,EQ,NE,MATCHES,BEGINS, orCONTAINS.Note: For BLOB or CLOB fields, you can only use the EQ (=) or NE (<>) operators. - expression
- Any valid ABL expression.
- THEN statement-or-block
- Any ABL statement or block. The statement or block executes when the
WHENclause evaluates to TRUE. - END COMPARES
- Closes the block of
WHENphrases. - NO-LOBS
- Directs the AVM to ignore large object data when comparing records that contain BLOB
or CLOB fields.CAUTION: When using this option, you get no warning if a LOB field has changed. This can lead to inappropriate results. Therefore, before using this option, you must understand the nature of your data and be sure that logic using this option will not result in inconsistent or out-of-date data in the database.
- NO-ERROR
- The NO-ERROR option is used to prevent the statement from raising
ERRORand displaying error messages.
Example
The following example copies a Customer database record into a temp-table
to represent an editable working copy, simulates two field changes, and then uses
BUFFER-COMPARE to detect which fields differ from the original. The
EXCEPT option excludes the primary-key field CustNum
from the bulk comparison. Because cChanged is defined as
CHARACTER, the result is a comma-separated list of the fields that failed
the comparison, sorted in ascending alphabetical order.
|
The MESSAGE statement displays a dialog similar to:
|
Notes
- At compile time,
BUFFER-COMPARE:- Fails to compile if any source-target field pair is not type compatible. An example of such a pair is a field that is LOGICAL in the source, but DECIMAL in the target.
- Excludes from the bulk comparison all
EXCEPTfield fields and allWHENfield fields. - Automatically excludes from the bulk comparison fields that appear in the source but not in the target.
- Tries to bind unqualified field names that appear in the
EXCEPTandUSINGoptions to the source buffer.
- At run time,
BUFFER-COMPARE:- Compares all fields not in the
EXCEPTphrase and all fields not in theWHENphrase for equality - Stores the result in the field that the
SAVEphrase specifies, if any - Evaluates each
WHENoption, executing it if its condition evaluates to TRUE
Note: This behavior is different from the behavior of the ABLCASEstatement, which executes only the firstWHENoption whose condition evaluates to TRUE. - Compares all fields not in the
- When comparing records that contain BLOB fields, the AVM performs a binary comparison on the BLOB data associated with the source and target records, and reports the results of the comparison.
- You cannot use the
BUFFER-COMPAREstatement to compare records that contain CLOB fields, unless one or both of the corresponding fields contain the Unknown value (?). However, you can convert CLOB fields to LONGCHAR values and use theEQ,GE,GT,LE,LT, orNEcomparison operator to compare the LONGCHAR values. - The statement supports three types of comparison for CLOB fields, namely, case-sensitive, binary and case-neutral.
- Use the
NO-LOBSoption with theBUFFER-COMPAREstatement to ignore large object data when comparing records that contain BLOB or CLOB fields. You can also use theEXCEPToption to exclude BLOB and CLOB fields from the compare. - When using
BUFFER-COMPAREin aWRITEtrigger procedure, LOB columns from theOLD BUFFERcannot be compared. Use theNO-LOBSoption or theEXCEPTclause to exclude BLOB and CLOB fields. See the TRIGGER PROCEDURE statement for details.