SELECT statement

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.

The first true WHEN condition is executed, and the remaining WHEN conditions are ignored. If none of the WHEN conditions is true and there is an OTHERWISE clause, then the OTHERWISE action is taken.
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>>

<OTHERWISE <action>> END

Figure 1 shows an example of coding a SELECT statement:

Figure 1. Example of 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