有关oracle pl/sql编程中游标和循环的问题

题目:
使用循环和游标实现,查询部门编号为10的员工信息,将查询结果按照员工编号从大到小的顺序排列,输出倒数第二行记录。

我的代码:

 declare
  empler emp%rowtype;
  i number:=0;
  n number;
  cursor emp_2 is select * from emp where deptno=10 order by empno desc;
begin
  select count(*) into n from emp where deptno=10;
  open emp_2;
  fetch emp_2 into empler;
  loop
    i:=i+1;
    if i=n-1
    then
      dbms_output.put_line('hh');
    end if;
    fetch emp_2 into empler;
    exit when emp_2%notfound;
  end loop;
end;

错误报告:
ORA-06550: 第 7 行, 第 50 列:
PL/SQL: ORA-00911: 无效字符
ORA-06550: 第 7 行, 第 3 列:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

请问哪里出错了?用这样的方法行的通吗?不行的话用什么方法?

http://www.cnblogs.com/maoniu602/archive/2013/03/01/2938758.html

fetch游标打开方式不会用可以使用for in的方式,for in 会自动关闭游标,fetch要自己手动关闭游标
而且顺序也有问题,先打开,再loop,再fetch
declare
empler emp%rowtype;
i number:=0;
n number;
cursor emp_2 is select * from emp where deptno=10 order by empno desc;
begin
select count(*) into n from emp where deptno=10;
open emp_2;
loop
fetch emp_2 into empler;
exit when emp_2%notfound;
i:=i+1;
if i=n-1
then
dbms_output.put_line('hh');
end if;
-- fetch emp_2 into empler;

end loop;
close emp_2;
end;