--修改任职信息表中的信息
--备份任职信息表
create table hi_psndoc_deptchg_bak as select * from hi_psndoc_deptchg
--执行如下语句,按照任职开始时间先后顺序将任职记录重新排序
update hi_psndoc_deptchg
set hi_psndoc_deptchg.recordnum =
(select a.rank
from (select pk_psndoc_sub,
pk_psnbasdoc,
begindate,
enddate,
cast(row_number()
over(partition by pk_psnbasdoc order by begindate desc) as int) - 1 as rank
from hi_psndoc_deptchg) a
where a.pk_psndoc_sub = hi_psndoc_deptchg.pk_psndoc_sub)
--修改履历信息表中的信息
--备份履历信息表
create table hi_psndoc_work_bak as select * from hi_psndoc_work
--执行如下语句,按照履历开始时间先后顺序将履历记录重新排序
update hi_psndoc_work
set hi_psndoc_work .recordnum =
(select a.rank
from (select pk_psndoc_sub,
pk_psnbasdoc,
begindate,
cast(row_number()
over(partition by pk_psnbasdoc order by begindate desc) as int) - 1 as rank
from hi_psndoc_work) a
where a.pk_psndoc_sub = hi_psndoc_work .pk_psndoc_sub)
--同步任职信息最新一条信息中的职务到工作信息的职务字段
update bd_psndoc set dutyname=(select pk_om_duty from hi_psndoc_deptchg where hi_psndoc_deptchg.pk_om_duty is not null and recordnum='0' and bd_psndoc.pk_psndoc=hi_psndoc_deptchg.pk_psndoc)
--更新工作信息中职务对应的职务级别和职务分类
--根据工作信息中的职务更新职务级别;
update bd_psndoc set pk_dutyrank=(select dutyrank from om_duty
where bd_psndoc.dutyname=om_duty.pk_om_duty);
--根据工作信息中的职务更新职务分类;
update bd_psndoc set series=(select series from om_duty
where bd_psndoc.dutyname=om_duty.pk_om_duty);