CREATE TABLE FCM_ERROSTAREFAREC (
    NRERROTAREFAREC     NUMBER 		   NOT NULL,
    NRTAREFARECORRENTE  NUMBER 		   NOT NULL,
    NMTAREFARECORRENTE  VARCHAR2(250),
    CDOPERRESPONSAVEL   VARCHAR2(12),
    CDOPERENCARREGADO   VARCHAR2(12),
    DTINICIAL           DATE,
    DTFINAL             DATE,
    DURACAO             NUMBER, 
    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_IDATIVO_FCM_ERROSTAREFAREC CHECK (IDATIVO IN ('S','N'))
)
/
ALTER TABLE FCM_ERROSTAREFAREC ADD CONSTRAINT PK_FCM_ERROSTAREFAREC PRIMARY KEY (NRERROTAREFAREC)
/
ALTER TABLE FCM_ERROSTAREFAREC 
  ADD CONSTRAINT FKFCM00166TAREFREC_ERTAREFAREC FOREIGN KEY (NRTAREFARECORRENTE)
      REFERENCES FCM_TAREFARECORRENTE (NRTAREFARECORRENTE)
/
CREATE INDEX FCM00166_FK ON FCM_ERROSTAREFAREC (NRTAREFARECORRENTE ASC)
/


ALTER TABLE FCM_TAREFARECORRENTE ADD IDERRO CHAR(1) DEFAULT 'N' NOT NULL
/
ALTER TABLE FCM_TAREFARECORRENTE ADD CONSTRAINT CK_IDERRO_FCM_TAREFARECORRENTE CHECK (IDERRO IN ('S', 'N'))
/