$Decode: Difference between revisions
(Automatically generated page update) |
|
(No difference)
|
Latest revision as of 13:13, 17 July 2014
The $DECODE function performs a table lookup and returns a decoded character string value. $DECODE is useful for printing descriptive information on reports when the records themselves contain only coded values.
$DECODE conserves space and minimizes the keystrokes required for requests by retaining only codes for fields. $DECODE takes two arguments:
$DECODE('table_name',resolve)
where
- table_name is the name of a table.
- resolve contains the code that is to be decoded.
Example
The state field contains a 2-character code. Full state names are printed.
BEGIN STATE: FOR EACH VALUE OF STATE IN ORDER STATE.VAL: FIND ALL RECORDS FOR WHICH STATE = VALUE IN STATE END FIND NO.IN.EACH: COUNT RECORDS IN STATE.VAL SKIP 1 LINE PRINT $DECODE ('STATE', VALUE IN STATE) - WITH COUNT IN NO.IN.EACH AT COLUMN 30 END FOR END