CREATE TABLE LOGCORTEOL (
  NRLOGCORTEOL NUMBER(10) NOT NULL, 
  CDFILIOPELOG VARCHAR2(4) NOT NULL, 
  DTLOGCORTEOL DATE NOT NULL, 
  CDCOMPRADOR VARCHAR2(12) NOT NULL, 
  CDOPERLANC VARCHAR2(12) NOT NULL, 
  CDFILCENT VARCHAR2(4) NOT NULL, 
  DTINICIAL DATE NOT NULL, 
  DTFINAL DATE NOT NULL, 
  DTINICIALAF DATE DEFAULT NULL NULL, 
  DTFINALAF DATE DEFAULT NULL NULL, 
  LISTAREGIAO VARCHAR2(500) NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL,
  CONSTRAINT PK_LOGCORTEOL PRIMARY KEY(NRLOGCORTEOL, NRORG)
)
/
ALTER TABLE LOGCORTEOL ADD CONSTRAINT CKC_IDATIVO_LOGCORTEOL CHECK (IDATIVO IN ('S','N'))
/
ALTER TABLE SOLICITA ADD (
  NRLOGCORTEOL NUMBER(10) DEFAULT NULL NULL, 
  CDMARCA VARCHAR2(5) DEFAULT NULL NULL
)
/
ALTER TABLE SOLICITA ADD CONSTRAINT FKSUP00311MARCA FOREIGN KEY (CDMARCA, NRORG) REFERENCES MARCA (CDMARCA, NRORG)
/
CREATE INDEX SUP00311_FK ON SOLICITA (CDMARCA ASC)
/
CREATE TABLE LOGCORTEOLCONS (
  NRLOGCORTEOLCONS NUMBER(10) NOT NULL, 
  NRLOGCORTEOL NUMBER(10) NOT NULL, 
  CDFILIOPELOG VARCHAR2(4) NOT NULL, 
  CDPRODARVOL VARCHAR2(10) DEFAULT NULL NULL, 
  QTESTOQ DOUBLE PRECISION DEFAULT NULL NULL, 
  QTPROGENTCONS DOUBLE PRECISION DEFAULT NULL NULL, 
  QTSOLIPROD DOUBLE PRECISION DEFAULT NULL NULL, 
  QTPROGENTAFOL DOUBLE PRECISION DEFAULT NULL NULL, 
  QTPROGENTAF DOUBLE PRECISION DEFAULT NULL NULL, 
  QTACUMULADAF DOUBLE PRECISION DEFAULT NULL NULL, 
  CDARVPROD VARCHAR2(20) DEFAULT NULL NULL, 
  IDCORTEOLCONS VARCHAR2(1) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NOT NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_LOGCORTEOLCONS PRIMARY KEY(NRLOGCORTEOLCONS, NRORG)
)
/
ALTER TABLE LOGCORTEOLCONS ADD CONSTRAINT FKSUP00312LOGCORTEOL FOREIGN KEY (NRLOGCORTEOL, NRORG) REFERENCES LOGCORTEOL (NRLOGCORTEOL, NRORG) ON DELETE CASCADE
/
ALTER TABLE LOGCORTEOLCONS ADD CONSTRAINT CKC_IDCORTEOLCONS_LOGCORTEOLCO CHECK (IDCORTEOLCONS IN ('S','N'))
/
ALTER TABLE LOGCORTEOLCONS ADD CONSTRAINT CKC_IDATIVO_LOGCORTEOLCONS CHECK (IDATIVO IN ('S','N'))