Determines the value of a column, literal, or variable and takes action based on that value.
EVALUATE {any_lit|_var|_col}
This command is equivalent to case/switch in C or Java. The general format of EVALUATE is:
EVALUATE {any_lit|_var|_col} WHEN comparison_operator {any_lit|_var|_col} SQR_Commands... [BREAK] [WHEN comparison_operator {any_lit|_var|_col} SQR_Commands... [BREAK]] [WHEN-OTHER SQR_Commands... [BREAK]] END-EVALUATE
A text or numeric column; a text, numeric, or date variable; or a text or numeric literal to use in the evaluation. In short, an evaluation argument.
Any valid comparison operator. See comparison operators in Table 45, Operators.
Evaluation expression. The evaluation argument is compared with the argument, beginning from the first WHEN. If the expression is TRUE, Production Reporting processes the commands after the WHEN. If the expression is FALSE, Production Reporting processes the next WHEN expression. Each WHEN must be on its own line.
If more than one WHEN expression appears directly before a set of commands, any one of them, if TRUE, causes the commands to execute.
Immediately exits EVALUATE. Use BREAK at the end of a set of commands.
Signifies the start of default commands to process if all other WHEN expressions are FALSE. WHEN-OTHER must appear after all other WHEN expressions.
EVALUATE is useful for branching to different commands depending on the value of a specified variable or column.
EVALUATE commands can be nested.
Evaluating a date variable or column with a string results in a date comparison (chronological, not a byte by byte comparison as is done for strings). The string must be in the proper format as follows:
For DATETIME columns and Production Reporting DATE variables, Production Reporting uses the format specified by SQR_DB_DATE_FORMAT, one of the database-dependent formats (see Table 61, Default Formats by Database), or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]'.
For DATE columns, Production Reporting uses the format specified by SQR_DB_DATE_ONLY_FORMAT. If not set, Production Reporting uses the format inTable 62, DATE Column Formats.
For TIME columns, Production Reporting uses the format specified by SQR_DB_TIME_ONLY_FORMAT. If not set, Production Reporting uses the format in Table 63, TIME Column Formats.
evaluate &code when = 'A' move 1 to #j break when = 'B' when = 'C' move 2 to #j ! Will happen if &code is B or C. break when > 'D' move 3 to #j ! Move 3 to #j and continue checking. when > 'H' add 1 to #j ! Add 1 to #j and continue checking. when > 'W' add 2 to #j break when-other if isnull (&code) do null_code else move 0 to #j ! Unknown code. end-if break end-evaluate