Consultor Eletrônico



Kbase P165349: 4GL/ABL: How to use the BUFFER-COMPARE() method in a database schema WRITE event trigger to compare
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   05/05/2010
Status: Unverified

GOAL:

4GL/ABL: How to use the BUFFER-COMPARE() method in a database schema WRITE event trigger to compare the OLD BUFFER and the NEW BUFFER.

GOAL:

How to use the BUFFER-COMPARE() method with an EXCEPT list in a database schema WRITE event trigger?

GOAL:

How to partially compare the NEW BUFFER with the OLD BUFFER in a database schema WRITE event trigger using the BUFFER-COMPARE method?

GOAL:

How to use a variable to store the EXCEPT list of the BUFFER-COMPARE() method in a database schema WRITE event trigger to partially compare the OLD BUFFER and the NEW BUFFER?

GOAL:

Sample TRIGGER PROCEDURE FOR WRITE OF a database table using a variable to store the fields to be excluded from comparison by the BUFFER-COMPARE method.

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)

FIX:

The following sample TRIGGER PROCEDURE FOR WRITE OF a database table uses a variable to store the EXCEPT field list to exclude some fields from the comparison made by the BUFFER-COMPARE method. When this WRITE event trigger fires, it will compare all the NEW BUFFER fields with those of the OLD BUFFER except the City and Country fields whose names are stored in the cExceptList variable. Please note that the MESSAGE statement used in this sample is for informational and testing purposes ONLY. In real life, some business logic will replace this MESSAGE statement:

TRIGGER PROCEDURE FOR WRITE OF Customer NEW BUFFER newBuff OLD BUFFER oldBuff.
DEFINE VARIABLE hnewBuff AS HANDLE NO-UNDO.
DEFINE VARIABLE holdBuff AS HANDLE NO-UNDO.
DEFINE VARIABLE lResult AS LOGICAL NO-UNDO.
DEFINE VARIABLE cExceptList AS CHARACTER NO-UNDO.
ASSIGN
hnewBuff = BUFFER newBuff:HANDLE
holdBuff = BUFFER oldBuff:HANDLE
cExceptList = "City,Country".
.
lResult = hnewBuff:BUFFER-COMPARE( holdBuff,"" ,cExceptList,"",YES).
MESSAGE "Are the fields equal?:~t" lResult
VIEW-AS ALERT-BOX INFO BUTTONS OK.