日期:2014-05-16 浏览次数:20472 次
方法一:
DECLARE l_sal emp.sal%TYPE; p_empno emp.empno%TYPE := 123; -- Invalid empno number BEGIN BEGIN SELECT sal INTO l_sal FROM emp WHERE empno = p_empno; EXCEPTION WHEN no_data_found THEN l_sal := 0; END; END; /
DECLARE l_sal emp.sal%TYPE; p_empno emp.empno%TYPE := 123; -- Invalid empno number BEGIN SELECT NVL(MAX(sal), 0) INTO l_sal FROM emp WHERE empno = p_empno; END; /
DECLARE l_sal emp.sal%TYPE; p_empno emp.empno%TYPE := 123; -- Invalid empno number BEGIN SELECT NVL(MAX(sal), 0) INTO l_sal FROM emp WHERE empno = p_empno HAVING count(1) <= 1; END; /