Larry,

An interesting concept.  You might consider using ITEMCNT
function to get number of columns to process and you could then
make the loop a definitive one.

In my case I am journaling the entire old record.  Plus I am
updating some record count fields and audit time and date fields
in a master record. So I need the complete OLD record in
variables for the INSERT command.  From my programming point of
view I try to minimize loops where ever possible.  

>From your code I assume all of you columns are the same data
type since you don't have a SET VAR command to set the variable
data type.  In my case I have diverse data types in the record
TEXT, INTEGER
--- Lawrence Lustig <[EMAIL PROTECTED]> wrote:

> <<
>  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
> 
> 
> 


Jim Bentley
American Celiac Society
[EMAIL PROTECTED]
tel: 1-504-737-3293

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Reply via email to