--Order 20015204.60

ALTER TABLE PACKINGNOTE
  ADD (PNREMARK VARCHAR2(1000) NULL);

update packingnote pn set pn.pnremark =
(select dp.remarkonpackingnote from distributionpoint dp where dp.distributionpoint_id = pn.distributionpoint_id
              and dp.packremarkenddate > pn.deliverydate)
              where pn.status_id in ( select s.status_id from status s where s.statustype='PN' and s.code in 
('10','20'));
commit;

update packingnote pn set pn.remark =
(select dp. remarkondeliverynote from distributionpoint dp where dp.distributionpoint_id = pn.distributionpoint_id
              and dp.packremarkenddate > pn.deliverydate)
              where pn.deliveryremark='n'
   and pn.status_id in ( select s.status_id from status s where s.statustype='PN' and s.code in 
('10','20'));
commit;