Some parts of the SELECT statement syntax contain repeatable items
where one or more repeatable items are delimited by a repeat separator.
The repeat separator for some repeat fragments is a comma (,), for
some others it is a constant or an operand, and for others it is a
space. If you specify more than one repeatable item, and the separator
is constant, Advanced SELECT prototyping inserts the correct separator
for you; otherwise, you must select the separator like any other element.
Let's take a simple example to show how you can build a fragment
of the SELECT clause with repeatable items. Say you want to show certain
information (specified in the rest of the SELECT statement) about
a company's employees, grouped by their skill type, grade, and the
year they started.
Press Enter. The syntax for the GROUP BY clause is displayed.
Notice that FM/Db2 shows the required keywords GROUP BY
in the partly-built SQL clause on the panel.
You can see that
the syntax for the GROUP BY clause consists of:
The required key words GROUP BY (shown on your screen in white),
The repeatable item groupingexpr (shown on your screen
in red), and
A comma (,) as the repeat separator.
Move the cursor to the groupingexpr fragment.
Press the InsRpt function key (F5). A pop-up panel is displayed
in which you can enter a column name.
Type SKILLTYPE in the pop-up panel.
Press the Exit function key (F3). The column name SKILLTYPE is
added to the GROUP BY clause.
Notice that, at this stage, FM/Db2 has not added a repeat
separator to the statement. If you are only specifying one repeatable
item, this is the correct syntax. However, if FM/Db2 detects that
you are specifying more than one repeatable item (as in the following
steps), it inserts the repeat separator.
Again, move the cursor to the groupingexpr fragment.
Press the InsRpt function key (F5) to display the pop-up panel.
Type EMPGRADE in the pop-up panel.
Press the Exit function key (F3). The repeat separator
and column name EMPGRADE are added to the GROUP BY clause.
Note: If you only require one repeatable item in the fragment, after
you move the cursor to the groupingexpr fragment (step 4), you can press the InsRpt function
key (F5) or Enter.