declare
ls_xsjbxx emp%rowtype;
enames varchar2(256);
begin
--查询员工信息
select * into ls_xsjbxx from emp t where t.EMPNO = '7369';
if sql%found then
dbms_output.put_line('员工号:' || ls_xsjbxx.EMPNO || ',姓名:' || ls_xsjbxx.ENAME);
end if;
--查询员工信息
FOR LS_ENAME IN ( SELECT T.* FROM emp T where t.DEPTNO = '20' ) LOOP
enames := LS_ENAME.ENAME || ',' ||enames;
END LOOP;
dbms_output.put_line('部门编号20的学员:' || rtrim(enames,',') );
--查询员工信息(不存在的员工)
select * into ls_xsjbxx from emp t where t.EMPNO = '600';
if sql%found then
dbms_output.put_line('员工号:' || ls_xsjbxx.EMPNO || ',姓名:' || ls_xsjbxx.ENAME);
end if;
exception
when no_data_found then
dbms_output.put_line('该部门600不存在');
end;