BUFFER-COMPARE statement

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

BUFFER-COMPARE source
  [ { EXCEPT | USING } field ... ] TO target 
  [ CASE-SENSITIVE | BINARY ]
  [ SAVE [ RESULT IN ] result-field ]
  [ [ EXPLICIT ] COMPARES ]:
     [ WHEN field compare-operator expression
        THEN statement-or-block ] ...
  [ END [ COMPARES ] ] [ NO-LOBS ] [ NO-ERROR ]
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 USING option is a positive version of the EXCEPT option.
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-COMPARE stops comparing when it encounters the first inequality.

EXPLICIT COMPARES
Opens a block of WHEN options. If you open the block, you must close it with END COMPARES.
WHEN field
Any data field in the source.

BUFFER-COMPARE removes this field from a USING list or adds this field to an EXCEPT list. 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, or CONTAINS.
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 WHEN clause evaluates to TRUE.
END COMPARES
Closes the block of WHEN phrases.
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 ERROR and displaying error messages.

Notes

See also

BUFFER-COPY statement , NO-ERROR option