--Order 20013760

ALTER TABLE REPAIRTYPE MODIFY (DEFAULTFOR DEFAULT 0);
 
COMMENT ON COLUMN REPAIRTYPE.DEFAULTFOR
  IS '0 = N/A
1 = Zipper
2 = Button
3 = Stitch
4 = Patch
5 = Emblem
6 = ID Code
7 = Other 
Fill default with 0. This attribute will not be used anymore. However for history and to avoid problems with views etc it is not (yet) removed.';

update repairtype rt set rt.repairpointerselectable = 'N'
where rt.defaultfor = 0;
commit;

update repairtype rt set rt.repairpointerselectable = 'Y'
where rt.defaultfor <> 0;
commit;

update repairtype rt set rt.repairpointersequence = rt.defaultfor;
commit;

ALTER TABLE REPAIRTYPE_DESC MODIFY (DESCRIPTION NULL);
ALTER TABLE REPAIRTYPE_DESC ADD (REPAIRPOINTERBUTTON1 VARCHAR2(10) NULL);
ALTER TABLE REPAIRTYPE_DESC ADD (REPAIRPOINTERBUTTON2 VARCHAR2(10) NULL);

update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Zipper'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 1);
commit;

update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Button'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 2);
commit;
      
update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Stitch'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 3);
commit;
       
update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Patch'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 4);
commit;
       
update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Emblem'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 5);
commit;
      
update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'ID Code'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 6);
commit;
      
update repairtype_desc rt_desc
   set rt_desc.repairpointerbutton1 = 'Other'
 where rt_desc.language_id in
       (select l.language_id
          from languages l
         where l.translatedescription = 'Y')
   and rt_desc.repairtype_id in
       (select rt.repairtype_id from repairtype rt where rt.defaultfor = 7);
commit;