<<
IF ((NHMainAddressLn <> .PHMainAddressLn) OR +
(NHMainAddressLn IS NOT NULL AND PHMainAddressLn IS NULL) OR +
(NHMainAddressLn IS NULL AND PHMainAddressLn IS NOT NULL)) OR +
... SAME TEST REPEATED FOR ADDITIONAL FIELDS ... THEN
SET VAR VFieldsAreDif = 'YES'
ENDIF
Think of repeating that for up to 8 fields.
>>
The way I handle this in triggers is to define a variable that holds a list of
the columns I'm interested in:
SET VAR tIAU_Columns = ('Company,Address1,Address2,City,State,Zip')
Then I iterate over the list, applying the logic separately to each column:
SET VAR tIAU_Count INT = 1
WHILE 1 = 1 THEN
SET VAR tIAU_Column = (SSUB(.tIAU_Columns, .tIAU_Count))
IF tIAU_Column IS NULL THEN
-- Ran out of columns
BREAK -- From WHILE loop
ENDIF
SELECT &tIAU_Column INTO vOldValue FROM TableName WHERE CURRENT OF SYS_OLD
SELECT &tIAU_Column INTO vNewValue FROM TableName WHERE CURRENT OF SYS_NEW
IF . . . -- Comparison Here
-- Do something here
ENDIF
SET VAR tIAU_Count = (.tIAU_Count + 1)
ENDWHILE
CLEAR VAR tIAU_%
RETURN
The logic is simple enough even for my feeble mind to follow, plus I can
determine which individual columns have changed (often what I'm doing is
journaling only the columns that changed, not the entire record). If you're
only concerned about whether _anything_ changed, you can bail out of the loop
after you "Do something here".
If you want to change the list of columns you're interested in, the only change
you need to make to the code is the first SET VAR tIAU_Columns statement --
that one variable drives all the logic later on.
--
Larry