Use the SELECT statement to write conditional statements in sequential form rather than IF-THEN-ELSE form. A SELECT statement consists of a SELECT keyword, one or more WHEN clauses, an optional OTHERWISE clause, and an END statement. You can specify the SELECT statement in one of two forms. In the first form shown below, you include the variable being tested after the SELECT statement. In the second form shown below, you include the variable being tested after the WHEN keyword.
SELECT (variable)
WHEN (value) <action>
.
.
.
<WHEN (value) <action>>
<WHEN (value) <action>>
<OTHERWISE <action>>
END
where:
SELECT (&DSOWNER)
WHEN ('IBMUSER1') SET &STORCLAS = 'PAYROLL'
WHEN ('IBMUSER2') SET &STORCLAS = 'TEST'
WHEN ('IBMUSER3') SET &STORCLAS = 'DEVELOP'
OTHERWISE SET &STORCLAS = 'NORMAL'
END
SELECT WHEN (relational
expression) <action> .
. .
<WHEN (relational expression) <action>>
<WHEN (relational expression) <action>>
Figure 1 shows an example of coding a SELECT statement:
SELECT
WHEN (&DSOWNER = 'IBMUSER') SET &STORCLAS = 'PAYROLL'
WHEN (&DSOWNER = 'IBMUSER2')
IF &ACCT_JOB = '1234' THEN
SET &STORCLAS = 'TEST'
ELSE
SET &STORCLAS = 'EVERYONE'
WHEN (&DSTYPE = 'TEMP') SET &STORCLAS = '
WHEN (&HLQ = 'CADAM') SET &STORCLAS = '
OTHERWISE SET &STORCLAS = 'COMMON'
END