%acc() Function

Top  Previous  Next

%acc() function is used to accumulate data within the given variable. This function can be used to concatenate strings or to increase/decrease numeric values.

Syntax:

%acc(target-symbol, accumulate-by-expression[, delimiter])
 

target-symbol

A target symbol where accumulated data will be stored.

accumulate-by-expression

The value of the expression will be accumulated in variable.

delimiter

This optional parameter can be used when accumulating string data and it will be placed between accumulate-by-expression values. The delimiter is not placed for the first accumulation.

Examples:
 

Example 1:

%acc(counter, 1) %// Increase the value of counter by 1

 
Example 2:

%acc(total, AMOUNT) %// Increase the value of total by the value of AMOUNT

 
AMOUNT    total 

------    --------

10        10

-3        7

4         11

 
Example 3:

%acc(where_clause, 'NAME = ''' + value + '''', ' OR ') 

 
value      where_clause 

----       --------------------------

John       NAME = 'John'

Susan      NAME = 'John' OR NAME = 'Susan' 

Jane       NAME = 'John' OR NAME = 'Susan' OR NAME = 'Jane'

 

See @accfs()