--order 20010638.60

--add new value for automatic flag
INSERT INTO AUTOMATICFLAG(AUTOMATICFLAG_ID, EVENT, SYSTEMUSER_ID, TIMESTAMP, SELECTABLE, DELETABLE, TRANSFERABLE) values ('20','Show on replaced item before replacement is active', Getminsystemuser(), sysdate, 'N', 'N', 'N');


--modify the size of the freetextitem in the uniqueitemflag table

alter table uniqueitemflag 
modify (freetextitem varchar2(60));

 
/*According to HVH not needed to update existing flag descriptions

update uniqueitemflag uif
set uif.freetextitem = uif.freetextitem ||','||
    (select  to_char(to_date(wo.entrydate), 'mm/dd/yyyy')
        from uniqueitem ui, uniqueitemnonpool up, workorder wo, workorderline wl
        where (ui.uniqueitem_id = up.uniqueitem_id) 
        and (up.replacementworkorderline_id = wl.workorderline_id) 
        and (wo.workorder_id = wl.workorder_id)
        and ui.uniqueitem_id = uif.uniqueitem_id
     )
where uif.uniqueitem_id in 
(select ui.uniqueitem_id 
  from uniqueitem ui, uniqueitemnonpool up, workorder wo, workorderline wl, uniqueitemflag uif1, automaticflag af
  where (ui.uniqueitem_id = up.uniqueitem_id) 
  and (up.replacementworkorderline_id = wl.workorderline_id) 
  and (wo.workorder_id= wl.workorder_id) 
  and ui.uniqueitem_id = uif1.uniqueitem_id
  and uif1.flag_id = af.flag_id
  and af.event='Replacement requested using replacement button'
);

commit;
*/



