z/OS DFSMSdfp Storage Administration
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


SELECT statement

z/OS DFSMSdfp Storage Administration
SC23-6860-01

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:
  • variable can be any read-only or read-write variable.
  • At least one WHEN keyword is mandatory.
  • value can be a constant or a FILTLIST name.
  • action can be an ACS statement, SELECT group, or a DO END group.
  • OTHERWISE is an optional keyword.
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
  • At least one WHEN keyword is mandatory.
  • relational expression can be a single comparison or it can be multiple comparisons joined by Boolean operators.
  • action can be an ACS statement, SELECT group, or a DO END group.
  • OTHERWISE is an optional keyword.

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

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014