SQL$HELP_OLD72.HLB  —  CASE Simple, Examples
    Example 1: Using the CASE control statement

    char x[11];
    long x_ind;
       EXEC SQL
          DECLARE ALIAS FOR FILENAME personnel ;

       EXEC SQL
          BEGIN
             CASE :x  INDICATOR :x_ind
                WHEN 'Abrams' THEN
                   DELETE FROM employees WHERE . . . ;
                WHEN NULL THEN
                   DELETE FROM employees WHERE . . . ;
                ELSE
                   DELETE FROM employees WHERE . . . ;
             END CASE ;
          END ;

    Example 2: Using a List of Literal Values with the Case Statement

    SQL> DECLARE :CODE CHAR(4);
    SQL> BEGIN
    cont>    JOB_LOOP:
    cont>        FOR :JOBFOR
    cont>          AS EACH ROW OF
    cont>          SELECT * FROM JOBS JOB
    cont>          DO
    cont>          SET :CODE = :jobfor.JOB_CODE;
    cont>            CASE :CODE
    cont>              WHEN 'ASCK' THEN
    cont>                 UPDATE JOBS
    cont>                 SET MINIMUM_SALARY=10000
    cont>                 WHERE JOB_CODE = :code;
    cont>              WHEN 'ADMN', 'JNTR', 'SCTR' THEN
    cont>                 UPDATE JOBS
    cont>                 SET MINIMUM_SALARY=15000
    cont>                 WHERE JOB_CODE = :code;
    cont>              ELSE
    cont>                 UPDATE JOBS
    cont>                 SET MINIMUM_SALARY=:jobfor.MINIMUM_SALARY*1.1
    cont>                 WHERE JOB_CODE=:code;
    cont>            END CASE;
    cont>        END FOR;
    cont> END;
    SQL>
Close Help