-- ABS-83284/ ABS-90258

-- create the system setting when it does not exist yet for all plants, setting its initial value to -1 (instead of the regular default 0)
create or replace procedure tempCreateSS as
begin
CreateSystemSetting('Scan Screens', 'CRBPAIRSCANNINGACTIVE', '-1', 'I', '0', 'N', 'N', 0, 2, '', 'New system setting to define if pair scanning is enabled.  If enabled, the button on outscanning may be activated. The user either has to activate it manually or it will be activated automatically after scanning an item that is setup for pair scanning.'|| chr(10) ||'0 = No pair scanning enabled'|| chr(10) ||'1 = Pair scanning enabled manually'|| chr(10) ||'2 = Pair scanning enabled automatically'|| chr(10) ||'This setting replaces the CRBPAIRSCANNING system setting as of 9.04.00', 'N');
CreateSystemSetting('Scan Screens', 'CRBPAIRSCANNING', 'N', 'B', 'N', 'Y', 'N', null, null, '', 'New system setting to define if pair scanning is enabled.  If enabled, the button on outscanning may be activated', 'N');
end tempCreateSS;
/
execute tempCreateSS;

drop procedure tempCreateSS;

-- only update those records that have not been updated before, once updated, the value will never be -1 again
update systemsetting sn
   set sn.value =
       (select decode(ov.value, 'Y', '1', '0')
          from systemsetting ov
         where ov.plant_id = sn.plant_id
           and ov.name = 'CRBPAIRSCANNING')
 where sn.name = 'CRBPAIRSCANNINGACTIVE'
   and sn.value = '-1';
commit;
