一、先cmd窗口用sqlplus 中用sd_hospital用户运行文件“20120929福州农保.sql”插入最新医保目录到临时表，本操作可在上班时间操作；
二、第一步完成后在下班没有医保病人的情况下运行下列语句
alter table BM_YBSFXM  disable all triggers;
alter table BM_YBSFdy  disable all triggers;
create table bm_ybsfxm20120929_old as select * from bm_ybsfxm;
create table bm_ybsfdy20120929_old as select * from bm_ybsfdy;

delete  from bm_ybsfxm where ybzxlb='@' and   fbbh00='3' and ZYFPXM in ('01','02','03') ; --and xmbh00 not in ('700000000001','700000000002','700000000003');


commit;

INSERT INTO bm_ybsfxm ("YBZXLB","XMBH00","FLAG00","ZYFPXM","MZFPXM","XMMC00","YPJX00","XMDW00","ZFBL00","SFYX00","SFYBXM","YBLB00","PYSM00",
"WBSM00","GXXLH0","YBBRLB","SFSX00","SCCJ00","YPGG00","BZ0000","FBBH00")  (select "YBZXLB","XMBH00","FLAG00","ZYFPXM","MZFPXM","XMMC00","YPJX00",
"XMDW00","ZFBL00","SFYX00","SFYBXM","YBLB00","PYSM00","WBSM00","GXXLH0","YBBRLB","SFSX00","SCCJ00","YPGG00","BZ0000","FBBH00" from zj_bm_ybsfxm);
commit;




--重新修正医保的自付比例等信息
update BM_YBSFDY a set (YBZYFP,YBMZFP,ZFBL00,SFYBXM,YBLB00,bz0000)= (select ZYFPXM,MZFPXM,ZFBL00,SFYBXM,YBLB00,bz0000 from BM_YBSFXM  where XMBH00=a.YBXMBH and YBZXLB=a.YBZXLB) where fbbh00 =3 and exists (select XMBH00 from BM_YBSFXM where YBZXLB=a.YBZXLB and a.YBXMBH=XMBH00 and fbbh00=a.fbbh00
              and (a.YBZYFP<>ZYFPXM OR A.YBMZFP<>MZFPXM or A.ZFBL00<>ZFBL00 OR A.SFYBXM<>SFYBXM OR A.YBLB00<>YBLB00 or a.bz0000<>bz0000)); 

/*
--把目录已经不存在的对应去除
update bm_ybsfdy set ybxmbh=null,zfbl00='1',sfybxm='N',yblb00=decode(sfyp00,'Y','7','2')
  where fbbh00 =3 and not exists (select 1 from bm_ybsfxm where ybxmbh=xmbh00 and ybzxlb=bm_ybsfdy.ybzxlb) and ybxmbh is not null ;
*/
commit;

alter table BM_YBSFdy  enable all triggers;
alter table BM_YBSFxm  enable all triggers;