/*order 502316*/
DROP INDEX XIF3LABELPRINTER;

      
      /*
      CHANGE REPORT for Table LABELPRINTER
          - change null constraint from NOT NULL to NULL of column APPLICATIONSERVER_ID
          - Adding column GENERATEPRINTFILE
      ACTION is ALTER or modify Table LABELPRINTER
      IMPACT ANALYSIS REPORT for ALTER or modify Table LABELPRINTER
          - index XIF3LABELPRINTER needs to be removed in order to proceed. 
      */

ALTER TABLE LABELPRINTER MODIFY (APPLICATIONSERVER_ID NULL);


ALTER TABLE LABELPRINTER ADD (GENERATEPRINTFILE    NUMBER DEFAULT 0 NOT NULL
                                   CONSTRAINT GeneratePrintFile_valid2
                                          CHECK (GENERATEPRINTFILE IN (0, 1)));

COMMENT ON COLUMN LABELPRINTER.GENERATEPRINTFILE IS '0 = Server (default)
1 = Client';

CREATE INDEX XIF3LABELPRINTER ON LABELPRINTER
(
       APPLICATIONSERVER_ID           ASC
);

---update field generateprintfile depending on databasesettings.printlabeldirectly

update labelprinter l
   set l.generateprintfile = (case when (select d.printlabelsdirectly
                      from databasesettings d) = 'Y' then 1 else 0 end);