declare
emprow emp%rowtype;
x exception;
cursor e_cur (dno number) is select * from emp where deptno=dno;
begin
open e_cur(&dno);
loop
fetch e_cur into emprow;
if e_cur%notfound then
raise x;
end if;
exit when e_cur%notfound;
dbms_output.put_line(emprow.empno||' '||emprow.job||' '||emprow.sal||' '||emprow.hiredate||' '||emprow.deptno);
end loop;
close e_cur;
exception
when x then
dbms_output.put_line('no deptno exists');
end;
/
