CREATE TABLE VAB_APURABENEFICIO
(
    NRAPURABENEFICIO  NUMBER                 NOT NULL,
	NRCALCULOFOLHA	  NUMBER				 NOT NULL,	
    NRVINCULOM        NUMBER                 NOT NULL,
    NRPESSOA          NUMBER                 NOT NULL,	
    NRBENEFICIOM      NUMBER                 NOT NULL,	
    DSTIPOBENEFICIO   VARCHAR2(20)           NOT NULL,		
    NREVENTOM         NUMBER                 NOT NULL,
    VRAPURABENEFICIO  FLOAT                  NOT NULL,
	NRORG             NUMBER 	     	DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
	IDATIVO           VARCHAR2(1)     	DEFAULT 'S' 					NOT NULL
      CONSTRAINT CKC_IDATIVO_VAB_APURABENEF 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',	
		CONSTRAINT VAB_APURABENEFICIO_PK PRIMARY KEY (NRAPURABENEFICIO)
)
/

CREATE INDEX HCM00057_FK ON VAB_APURABENEFICIO (NREVENTOM ASC)
/

CREATE INDEX HCM00058_FK ON VAB_APURABENEFICIO (NRVINCULOM ASC)
/

CREATE INDEX HCM00059_FK ON VAB_APURABENEFICIO (NRPESSOA ASC)
/

CREATE INDEX HCM00060_FK ON VAB_APURABENEFICIO (NRBENEFICIOM ASC)
/

CREATE INDEX HCM00061_FK ON VAB_APURABENEFICIO (NRCALCULOFOLHA ASC)
/

ALTER TABLE VAB_APURABENEFICIO
    ADD CONSTRAINT FKHCM00057_NREVENTOM FOREIGN KEY  (NREVENTOM)
       REFERENCES FPA_EVENTOM (NREVENTOM)
/

ALTER TABLE VAB_APURABENEFICIO
    ADD CONSTRAINT FKHCM00058_NRVINCULOM FOREIGN KEY  (NRVINCULOM)
       REFERENCES GPE_VINCULOM (NRVINCULOM)
/

ALTER TABLE VAB_APURABENEFICIO
    ADD CONSTRAINT FKHCM00059_NRPESSOA FOREIGN KEY  (NRPESSOA)
       REFERENCES GPE_PESSOA (NRPESSOA)
/

ALTER TABLE VAB_APURABENEFICIO
    ADD CONSTRAINT FKHCM00060_NRBENEFICIOM FOREIGN KEY  (NRBENEFICIOM)
       REFERENCES VAB_BENEFICIOM (NRBENEFICIOM)
/

ALTER TABLE VAB_APURABENEFICIO
    ADD CONSTRAINT FKHCM00061_NRCALCULOFOLHA FOREIGN KEY  (NRCALCULOFOLHA)
       REFERENCES VAB_BENEFICIOM (NRCALCULOFOLHA)
/