ORACLE PL/SQL程式設計詳解之三:PL/SQL流程控制語句(不給規則,不成方圓)
阿新 • • 發佈:2019-01-09
DECLARE
v_first_name employees.first_name%TYPE;
v_job_id employees.job_id%TYPE;
v_salary employees.salary%TYPE;
v_sal_raise NUMBER(3,2);
BEGINSELECT first_name, job_id, salary INTO
v_first_name, v_job_id, v_salary
FROM employees WHERE employee_id =&emp_id;
CASEWHEN v_job_id ='PU_CLERK'THENIF v_salary <3000THEN v_sal_raise := .08;
ELSE v_sal_raise := .07;
ENDIF;
WHEN v_job_id ='SH_CLERK'THENIF v_salary <4000THEN v_sal_raise := .06;
ELSE v_sal_raise := .05;
ENDIF;
WHEN v_job_id ='ST_CLERK'THENIF v_salary <3500THEN v_sal_raise := .04;
ELSE v_sal_raise := .03;
ENDIF;
ELSE
DBMS_OUTPUT.PUT_LINE('該崗位不漲工資: '||v_job_id);
ENDCASE;
DBMS_OUTPUT.PUT_LINE(v_first_name||'的崗位是'||v_job_id
||'、的工資是'||v_salary
||'、工資漲幅是'||v_sal_raise);
END;
v_first_name employees.first_name%TYPE;
v_job_id employees.job_id%TYPE;
v_salary employees.salary%TYPE;
v_sal_raise NUMBER(3,2);
BEGINSELECT first_name, job_id, salary INTO
v_first_name, v_job_id, v_salary
FROM employees WHERE employee_id =&emp_id;
ELSE v_sal_raise := .07;
ENDIF;
WHEN v_job_id ='SH_CLERK'THENIF v_salary <4000THEN v_sal_raise := .06;
ELSE v_sal_raise := .05;
ENDIF;
WHEN v_job_id ='ST_CLERK'THENIF v_salary
ELSE v_sal_raise := .03;
ENDIF;
ELSE
DBMS_OUTPUT.PUT_LINE('該崗位不漲工資: '||v_job_id);
ENDCASE;
DBMS_OUTPUT.PUT_LINE(v_first_name||'的崗位是'||v_job_id
||'、的工資是'||v_salary
END;