CREATE OR REPLACE FUNCTION sf_ys_getybtstsxz(ad_YPNM00 number, ad_FBBH00 number, as_YBZXLB char, as_YBBRLB char ) return varchar2 is Vresult BM_YBSFXM.BZ0000%type; Vcount number(5); Vcount1 number(5); --MODIFICATION HISTORY --Person Date Comments --dsm 2019.10.10 create for MZYS-20170927-001 begin Vcount:=0; select count(*) into Vcount1 from XT_XTCS00 where NAME00='ZS_ZSYZYPSFDYBFSFS' and substr(value0,1,1)='Y'; begin select count(*) into Vcount from BM_TYZD00 where ZDMC00='医保发送自费选择药品目录' and DJ0000=ad_YPNM00; if Vcount>0 or Vcount1>0 then select b.BZ0000 into Vresult from BM_YBSFDY a,BM_YBSFXM b,BM_YD0000 c where a.SFYP00='Y' and a.YBXMBH=b.XMBH00 and a.YBZXLB=b.YBZXLB and a.SFXMID=c.YPNM00 and c.YPNM00=ad_YPNM00 and a.FBBH00=3 and a.YBZXLB='1' and a.YBBRLB in (as_YBBRLB,'Z') and b.BZ0000 is not null --and b.BZ0000 not like '%国家基药%' and b.BZ0000 not like '%增补%' ; end if; exception when others then Vresult:=''; if Vcount>0 then Vresult:='根据病人情况选择自费或医保.'; end if; end; return Vresult; end; /