Plsql 需要修复代码,以便使用部门名称从员工中查找名字和姓氏

Plsql 需要修复代码,以便使用部门名称从员工中查找名字和姓氏,plsql,oracle11g,Plsql,Oracle11g,下面的代码用于使用部门名称从员工中查找名字和姓氏。我得到错误:错误(13,8):PLS-00103,但我不知道如何修复它。有什么建议吗?提前谢谢 create or replace procedure xx(a in varchar2) as cursor b is select department_name, first_name, last_name from employees; c employees%rowtype; begin open b; loop fetch b in

下面的代码用于使用部门名称从员工中查找名字和姓氏。我得到错误:错误(13,8):PLS-00103,但我不知道如何修复它。有什么建议吗?提前谢谢

create or replace procedure xx(a in varchar2)
as
cursor b is select department_name, first_name, last_name from employees;
c employees%rowtype;
begin
open b;
loop
    fetch b into c;
    exit when b%notfound;
        if a = c.department_name then
        dbms_output.put_line(c.first_name);
        dbms_output.put_line(c.last_name);
        elseif DBMS_OUTPUT.PUT_LINE(c.last_name);
        end if;
end loop;
close b;
end;
试试下面这个:

create or replace procedure xx(a in varchar2)
as
cursor b is select department_name, first_name, last_name from employees;
c b%rowtype;
begin
open b;
loop
    fetch b into c;
    exit when b%notfound;
        if a = c.department_name then
        dbms_output.put_line(c.first_name);
        dbms_output.put_line(c.last_name);
        elseif DBMS_OUTPUT.PUT_LINE(c.last_name);
        end if;
end loop;
close b;
end;
错误(13,8)在下面的行中

elseif DBMS_OUTPUT.PUT_LINE(c.last_name);
您正在使用elsif,但没有任何条件进行测试。 如果您没有更多的条件进行比较/测试,那么最好使用else而不是elsif

create or replace procedure xx(a in varchar2)
as
cursor b is select department_name, first_name, last_name from employees;
c employees%rowtype;
begin
open b;
loop
    fetch b into c;
    exit when b%notfound;
        if a = c.department_name then
            dbms_output.put_line(c.first_name);
            dbms_output.put_line(c.last_name);
        else 
            DBMS_OUTPUT.PUT_LINE(c.last_name);
        end if;
end loop;
close b;
end;
注意:语法错误显示您可能出错的行和列