ALTER TABLE CONFCARD ADD IDOTMCOLUNAFIXA VARCHAR2(1) NULL
/

ALTER TABLE CONFCARD ADD IDOTMNAOCONSCOR VARCHAR2(1) NULL
/

ALTER TABLE CONFCARD ADD IDOTMNAOCONSMOD VARCHAR2(1) NULL
/

CREATE TABLE OTMREGRAFLEX (
    NROTMREGRAFLEX    NUMBER NOT NULL,
    IDFLEXIVEL        VARCHAR2(1) DEFAULT 'N',   
    NRORDEMREGRA      NUMBER NOT NULL,
    DSREGRAFRLEX      VARCHAR2(200),
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDFLEXIVEL_OTMREGRAFLEX CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT CKC_IDATIVO_OTMREGRAFLEX CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_OTMREGRAFLEX PRIMARY KEY (NROTMREGRAFLEX)
)
/
BEGIN
   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (1,1,'PERMITE_INGREDIENTE_MESMO_DIA'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;
   
   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (2,2,'PERMITE_INGREDIENTE_DIA_SEGUIDO'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END; 

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (3,3,'PERMITE_COR_MESMO_DIA'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END; 

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (4,4,'PERMITE_MODOPREPARO_MESMO_DIA'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END; 

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (5,5,'PERMITE_GRUPOPRATO_MAIOR_FREQ_MES'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END; 

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (6,6,'PERMITE_GRUPOPRATO_MAIOR_FREQ_SEMANA'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END; 

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (7,7,'PERMITE_PRATO_MAIOR_FREQ_MES'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;    

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (8,8,'PERMITE_PRATO_MAIOR_FREQ_SEMANA'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (9,9,'PERMITE_GRUPOPRATO_DIA_RESTRITO'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;

   BEGIN INSERT INTO OTMREGRAFLEX(NROTMREGRAFLEX, NRORDEMREGRA, DSREGRAFRLEX) VALUES (10,10,'PERMITE_PRATO_GRUPO_COMB_RESTRITO'); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;

   BEGIN INSERT INTO OTIMIZADORITEM(NROTIMIZADORITEM, DSOTIMIZADORITEM, NRORDEMITEM) VALUES (31, 'REGRAS A FLEXIBILIZAR NO POS CENARIO',6.5); COMMIT;
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN NULL; END;
END;
/