CREATE OR REPLACE FUNCTION SF_ZS_LJ_RYZDMC_ZYDZBL ( PZYID00 in number, --住院ID PZDLB00 in char, --诊断类别 PZDMBZ0 in char default '0' --0取诊断名称,1取诊断码 ) -- MODIFICATION HISTORY -- Person Date Comments -- 阮炳辉 2014.12.11 create for DZBL-20141210-007 -- wuzy 2018.06.01 入径患者查询、出径患者查询界面报错查询全院报错,扩展临时变量 update for ZYDZBL-20180504-001 return varchar2 is V_RETURN_ZDXX varchar2(4000); --返回诊断信息 LS_NUM number(4); cursor CUR_ZDXX is select ZDMC00,ZDM000 from VW_BQ_BRZDXX where ZYID00=PZYID00 and ZDLB00=PZDLB00; BEGIN V_RETURN_ZDXX:=''; LS_NUM:=0; for ZDXX in CUR_ZDXX loop if PZDMBZ0='0' then if LS_NUM=0 then V_RETURN_ZDXX:=ZDXX.ZDMC00; else V_RETURN_ZDXX:=V_RETURN_ZDXX||'/'||ZDXX.ZDMC00; end if; else if LS_NUM=0 then V_RETURN_ZDXX:=ZDXX.ZDM000; else V_RETURN_ZDXX:=V_RETURN_ZDXX||'/'||ZDXX.ZDM000; end if; end if; LS_NUM:=LS_NUM+1; end loop; return V_RETURN_ZDXX; end;