-- ABS-24854/ ABS-28835

ALTER TABLE GARMENTDISPENSER ADD (USESECONDARYID VARCHAR2(1) DEFAULT 'N' NOT NULL 
                                  CONSTRAINT YN_VALIDATIONFIELD287 CHECK (USESECONDARYID IN ('Y','N')));

create or replace procedure updategarmentdispenser is
  DBSetting varchar2(10);
begin
  select dbs.code into DBSetting from databasesettings dbs;
  if DBSetting = 'LTS' then
    for x in (select cgd.customer_id
                from customergarmentdispenser cgd
               where cgd.interface = 6) loop
      update garmentdispenser gd
         set gd.usesecondaryid = 'Y'
       where gd.customer_id = x.customer_id;
    end loop;
    commit;
  end if;
end updategarmentdispenser;
/

execute updategarmentdispenser;

drop procedure updategarmentdispenser;