日期:2014-05-16 浏览次数:20822 次
declare
v_empno emp.empno%type;
v_ename emp.ename%type;
v_sal emp.sal%type;
v_deptno emp.deptno%type;
begin
select empno,ename,sal,deptno into v_empno,v_ename,v_sal,v_deptno from emp where
ename='Smith';
dbms_output.put_line(v_empno||' '||v_ename||' '||v_sal||' '||v_deptno);
exception
when no_data_found then
insert into emp(empno,ename,sal,deptno) values(2012,'Smith',7500,50);
when too_many_rows then
for v_emp in (select * from emp where ename='Smith') loop
dbms_output.put_line(v_emp.empno||' '||v_emp.ename||' '||v_emp.sal||'
'||v_emp.hiredate||' '||v_emp.deptno);
end loop;
end;