日期:2014-05-16  浏览次数:20401 次

根据rfid获取出生日期变更记录
create or replace procedure get_BirthdayHis_By_RFID(i_rfid in varchar2,o_birthday_his out varchar2) is
v_birthdayLast date;
v_birthday date;
v_updateTime date;
v_result varchar2(2048);

cursor r is
select h.birthday as birthday
       ,case when h.update_time is null then h.his_time else h.update_time end as updateTime 
       ,decode(h.upt_user, null, decode(e.type, '112', e.name , p.name), h.upt_user) as reader   
from his_animal_info h,tbl_people_manager p,tbl_enterprise e
where h.birthday is not null and h.rfid = i_rfid
  and h.card_id = p.card_id(+) 
  and h.card_id = e.card_id(+)     
order by h.update_time;

thedata r%rowtype;

begin
  open r;
  loop
    fetch r
      into thedata;
    exit when r%notfound;

    v_birthday := thedata.birthday;
    v_updateTime := thedata.updateTime;
    if(v_birthday <> v_birthdayLast) then
        v_result := v_result||to_char(v_updateTime,'yyyy-mm-dd hh24:mi:ss')||chr(10)||'修改人:'||thedata.reader||chr(10)||'出生日期:'||to_char(v_birthday,'yyyy-mm-dd')||chr(10)||'-------------'||chr(10);/*字符串中换行用chr(10)*/
    end if;
    v_birthdayLast := v_birthday;
  end loop;

  o_birthday_his := v_result;

end;