执行我的pl / sql代码时出错

时间:2013-09-26 13:36:02

标签: plsql cursor syntax-error case

这是我的pl / sql块

declare 
b_emp_no employees.emp_no%type;
cursor c_employees is 
select emp_no from employees;
begin
open c_employees;
loop
fetch c_employees  into b_emp_no;
exit when c_employees%notfound;
end loop;
case b_emp_no
when b_emp_no=1 then
dbms_output.put_line('employee number is 1');
when b_emp_no=2 then
dbms_output.put_line('employee number is 2');
when b_emp_no=3then
dbms_output.put_line('employee number is 3');
when b_emp_no=4 then
dbms_output.put_line('employee number is 4');
when b_emp_no=5 then
dbms_output.put_line('employee number is 5');
when b_emp_no=6 then
dbms_output.put_line('employee number is 6');
when b_emp_no=7 then
dbms_output.put_line('employee number is 7');
when b_emp_no=8 then
dbms_output.put_line('employee number is 8');
when b_emp_no=9 then
dbms_output.put_line('employee number is 9');
when b_emp_no=10 then
dbms_output.put_line('employee number is 10');
when b_emp_no=11 then
dbms_output.put_line('employee number is 11');
else 
dbms_output.put_line('employees numbers:'||b_emp_no);
close c_employees;
end;

执行上面的pl / sql block.getting错误是

ORA-06550: line 37, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:

   case
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

我没有得到它显示此错误的地方。请纠正我的错误。我没能纠正这个错误

1 个答案:

答案 0 :(得分:1)

根据语法的要求,代码中没有“END CASE”。

http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/case_statement.htm