declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE TABLE DESCONTO_CONTRATO (
                        DESCONTOCONTRATO_ID NUMBER(7,0) PRIMARY KEY,
                        CONTRATO_ID NUMBER(7,0),                         
                        DATA_INICIAL DATE,
                        DATA_FINAL DATE,
						PORCENTAGEM NUMBER(5,2), 
                        INDDESCONTO NUMBER(1,0),
                        USUARIO_ID NUMBER(7,0),
                        ACTIVO NUMBER(1,0),
                        FECMODIF DATE, 
                        CONSTRAINT fk_contrato_desconto FOREIGN KEY (CONTRATO_ID) REFERENCES CONTRATO_CORPORATIVO(CONTRATO_ID),
                        CONSTRAINT fk_usuario_contrato_desconto FOREIGN KEY (USUARIO_ID) REFERENCES USUARIO(USUARIO_ID)
                    )';
  exception when object_exists then null;
end;
/

declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE SEQUENCE "DESCONTO_CONTRATO_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE';
  exception when object_exists then null;
end;
/
