You are here: Home > Knowledge Refreshers

KR editions 26 to 27


KR - 26: Projection and selection (DB2)

Found a couple of interesting terms used in Database systems: projection and selection

Projection and Selection: 

  • Selection occurs when we use a WHERE clause on a query. It's like choosing only a particular number of rows from the table. Ex:

    SELECT * FROM EMPLOYEE_T where emp_id>100; 
  • A projection occurs when we choose only certain columns from the table. For ex:

    SELECT EMP_ID, EMP_NAME from EMPLOYEE_T; 

    In this case we are selecting only 2 columns rather than all. 
  • Generally we'll be using selection and projection together. For ex:
    SELECT emp_id, emp_name FROM EMPLOYEE_T where emp_id>100;

KR- 27 (JCL IF statement)

We'll take a dip in JCL for this edition: Idea contributed by Rajat

In a JCL, for a step, if the condition in the COND clause is true then the step won't be executed. 

If you want to execute a step (say STEP3) if STEP1 or STEP2 were successful, then rather than COND you could use the IF statement (it's easier and simple). 

//CHECK IF (STEP02.RC = 0 OR STEP03.RC = 0) THEN 
//STEP04 EXEC PGM=IEBGENER 
//SYSPRINT DD SYSOUT=* 
.......

//CHECKEND ENDIF

CHECK and CHECKEND are just ordinary names (we can use any other name). IF and ENDIF are keywords. Enclose whatever you want to execute conditionally within IF and ENDIF. In our example we've enclosed STEP04 within them. 

RC is the return code (we can selectively check for the RC of particular steps as done in the above example). Thus STEP04 will execute only if either STEP02 or STEP03 executed successfully.


Go back to the main contents page