-- ALBERTINA
--Description:
--zmeny provadene pres UFO_OPS je mozne sledovat v ODS pomoci selectu
select  inst_pt.inst_pt_key,
       inst_pt.uni_pt_key,
       inst_pt.ico_num,
       inst_pt.bus_name,
       uni_pt_seg.note,
    nvl(seg.descr,
           'ICO neni na BL/WL v ODS, existuje ale v ALBERTINE -  MWF658 vrati WL_flag=1') as typ_WL_BL,
       uni_pt_seg.expire_date,
       uni_pt_seg.ins_dt



  from ODS_L1_OWNER.inst_pt inst_pt
  left join ODS_L1_OWNER.uni_pt_seg uni_pt_seg on inst_pt.uni_pt_key =
                                                  uni_pt_seg.uni_pt_key
                                              and uni_pt_seg.del_flag = 0



  left join ODS_L1_OWNER.Seg seg on uni_pt_seg.seg_key = seg.seg_key
                                and uni_pt_seg.del_flag = 0 -- zaznam je aktivni
                                and uni_pt_seg.src_sys_id = 'EXA01'
                                and uni_pt_seg.del_flag = 0
 where 1 = 1
   and inst_pt.ico_num = '#ICO'
   and inst_pt.src_sys_id in ('EXA01', -- CCK BL
        'ALB0' -- ICO  z Albertina
       , 'CSU0' -- ICO z ARES
       )



 order by uni_pt_seg.ins_dt desc