--程序段3-----------------------------------------------------------------------------------------
open before_hride_date_cursor for select * from emp e where to_char(e.hiredate,'yyyy-mm-dd') > in_job_date for update;
loop
fetch before_hride_date_cursor into emp_record;
exit when before_hride_date_cursor%notfound;
update emp e set e.sal = e.sal+500 where e.empno = emp_record.empno;
end loop;
dbms_output.put_line('共有:'||before_hride_date_cursor%rowcount||'名员工是'||in_job_date||'前入职的,他们的工资都加了500');
close before_hride_date_cursor;
dbms_output.put_line('调整'||in_job_date||'前入职的所有的员工工资后的信息如下---------------------------');
open emp_cursor;
--使用简单loop循环获取数据
loop
--注意是fetch 游标 into 记录类型 ,不要搞反了啊
fetch emp_cursor
into emp_record;
exit when emp_cursor%notfound;
dbms_output.put_line('员工编号:' || emp_record.empno || ' 员工名字:' ||
emp_record.ename || ' 员工职位:' || emp_record.job ||
' 员工入职日期:' || emp_record.hiredate || ' 员工部门号:' ||
emp_record.deptno||' 员工工资:'||emp_record.sal);
end loop;
close emp_cursor;
exception
when others then
dbms_output.put_line(sqlcode||' ,'||sqlerrm);
end;
--测试部分
begin
practice_cursor(900, '1982-02-01');
end;
select * from emp e where to_char(e.hiredate,'yyyy-mm-dd') > '1980-02-01'