ALTER TABLE FCM_LOCALCLI ADD DSCORIDLOCAL VARCHAR2(30) NULL
/

ALTER TABLE FCM_ATIVIDADE ADD DSCORIDATIVIDADE VARCHAR2(30) NULL
/

CREATE TABLE FCM_LOGTRANSFAGEND (
    NRLOGTRANSFAGEND     NUMBER NOT NULL,
    NRCHECKLISTAGEND     NUMBER NOT NULL,
    NRFUNCIONARIOORIGEM  NUMBER NOT NULL,
    DTHORAAGENDORIG      NUMBER NOT NULL,
    NRFUNCIONARIODESTINO NUMBER NOT NULL,
    DTHORAAGENDDESTINO   NUMBER NOT NULL,
    NRORG             NUMBER 	     DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' 					NOT NULL
      CONSTRAINT CK_IDATIVO_LOGTRNFAGEND CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  						NULL,
    DTULTATU          DATE                  						NULL,
    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'
)
/

ALTER TABLE FCM_LOGTRANSFAGEND ADD CONSTRAINT PK_FCM_LOGTRANSFAGEND PRIMARY KEY (NRLOGTRANSFAGEND)
/

CREATE TABLE FCM_LOGTRANSFGERCHK (
    LOGTRANSFGERCHK      NUMBER NOT NULL,
    NRGERENCIAMENTOCHK   NUMBER NOT NULL,
    NRFUNCIONARIOORIGEM  NUMBER NOT NULL,
    DTHORAAGENDORIG      NUMBER NOT NULL,
    NRFUNCIONARIODESTINO NUMBER NOT NULL,
    DTHORAAGENDDESTINO   NUMBER NOT NULL,
    NRORG             NUMBER 	     DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' 					NOT NULL
      CONSTRAINT CK_IDATIVO_LOGTRNFGERCHK CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  						NULL,
    DTULTATU          DATE                  						NULL,
    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'
)
/

ALTER TABLE FCM_LOGTRANSFGERCHK ADD CONSTRAINT PK_FCM_LOGTRANSFGERCHK PRIMARY KEY (LOGTRANSFGERCHK)
/

CREATE TABLE FCM_HIERARQUIAFUNC (
    NRHIERARQUIAFUNC     NUMBER NOT NULL,
    NMHIERARQUIAFUNC     NUMBER NOT NULL,
    NRFUNCIONARIO        NUMBER NOT NULL,
    NRFUNCIONARIOPAI     NUMBER,
    NRORG             NUMBER 	     DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S' 					NOT NULL
      CONSTRAINT CK_IDATIVO_HIERARQUIAFUNC CHECK (IDATIVO IN ('S','N')),
    DTINCLUSAO        DATE                  						NULL,
    DTULTATU          DATE                  						NULL,
    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'
)
/

ALTER TABLE FCM_HIERARQUIAFUNC ADD CONSTRAINT PK_FCM_HIERARQUIAFUNC PRIMARY KEY (NRHIERARQUIAFUNC)
/

CREATE INDEX FCM00057_FK ON FCM_HIERARQUIAFUNC (NRFUNCIONARIO ASC)
/

ALTER TABLE FCM_HIERARQUIAFUNC 
  ADD CONSTRAINT FKFCM00057FUNC_HIERFUNC FOREIGN KEY (NRFUNCIONARIO)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIO)
/

CREATE INDEX FCM00058_FK ON FCM_HIERARQUIAFUNC (NRFUNCIONARIOPAI ASC)
/

ALTER TABLE FCM_HIERARQUIAFUNC 
  ADD CONSTRAINT FKFCM00058FUNC_HIERFUNCPAI FOREIGN KEY (NRFUNCIONARIOPAI)
      REFERENCES FCM_FUNCIONARIO (NRFUNCIONARIOPAI)
/

ALTER TABLE FCM_CHECKLISTAGEND ADD DTHRFINALAGEND DATE
/

ALTER TABLE FCM_GERENCIAMENTOCHK ADD DTHRFINALAGEND DATE
/