DECLARE v_empno employees.employee_id%TYPE :=&empno; V_salary employees.salary%TYPE; V_comment VARCHAR2(35); BEGIN SELECT salary INTO v_salary FROM employees WHERE employee_id = v_empno; IF v_salary <1500THEN V_comment:='太少了,加点吧~!'; ELSIF v_salary <3000THEN V_comment:='多了点,少点吧~!'; ELSE V_comment:='没有薪水~!'; ENDIF; DBMS_OUTPUT.PUT_LINE(V_comment); exception when no_data_found then DBMS_OUTPUT.PUT_LINE('没有数据~!'); when others then DBMS_OUTPUT.PUT_LINE(sqlcode ||'---'|| sqlerrm); END;
DECLARE v_empno employees.employee_id%TYPE :=&empno; V_salary employees.salary%TYPE; V_comment VARCHAR2(35); BEGIN SELECT salary INTO v_salary FROM employees WHERE employee_id = v_empno; IF v_salary <1500THEN V_comment:='太少了,加点吧~!'; ELSIF v_salary <3000THEN V_comment:='多了点,少点吧~!'; ELSE V_comment:='没有薪水~!'; ENDIF; DBMS_OUTPUT.PUT_LINE(V_comment); exception when no_data_found then DBMS_OUTPUT.PUT_LINE('没有数据~!'); when others then DBMS_OUTPUT.PUT_LINE(sqlcode ||'---'|| sqlerrm); END;