显示16行出错?

来源:5-2 案例:统计每年入职的员工人数

慕前端0336099

2016-04-05 16:55

set serveroutput on

declare

cursor guangbiao01 is select to_char(hiredate,'yyyy') FROM emp;

hiredata  VARCHAR2(4);

a80 number:=0;

a81 number:=0;

a82 number:=0;

a87 number:=0;

begin

open guangbiao01;

LOOP

fetch guangbiao01 INTO hiredata;

EXIT when guangbiao01%notfound;

if hiredata ='1980' then a81:=a81+1;

ELSIF hriedata ='1981' then a81:=a81+1;

elsif hiredata ='1982' then a82:=a82+1;  这里说是有问题大神们给看看啊受不了了

else hriedata ='1987' then a87:=a87+1;

end if;

end loop;

close guangbiao01;

dbms_output.put_line('tol'||(a80+a81+a82+a87));

dbms_output.put_line(a80);

dbms_output.put_line(a81);

dbms_output.put_line(a82);

dbms_output.put_line(a87);

end;

/


写回答 关注

1回答

  • inverted_demon
    2016-05-18 14:53:34
    已采纳

    set serveroutput on

    declare

    cursor guangbiao01 is select to_char(hiredate,'yyyy') FROM emp;

    hiredata  VARCHAR2(4);

    a80 number:=0;

    a81 number:=0;

    a82 number:=0;

    a87 number:=0;

    begin

    open guangbiao01;

    LOOP

    fetch guangbiao01 INTO hiredata;

    EXIT when guangbiao01%notfound;

    if hiredata ='1980' then a81:=a81+1;

    ELSIF hiredata ='1981' then a81:=a81+1;--这里写错

    elsif hiredata ='1982' then a82:=a82+1; 

    else  a87:=a87+1;                      --这里写错

    end if;

    end loop;

    close guangbiao01;

    dbms_output.put_line('tol'||(a80+a81+a82+a87));

    dbms_output.put_line(a80);

    dbms_output.put_line(a81);

    dbms_output.put_line(a82);

    dbms_output.put_line(a87);

    end;

    /


    慕前端033...

    非常感谢!

    2016-05-29 11:25:03

    共 1 条回复 >

Oracle数据库开发必备利器之PL/SQL基础

Oracle数据库高级开发必备的基础,通过实例带你熟练掌握

75048 学习 · 208 问题

查看课程

相似问题