CREATE TABLE DOCSANGRIA(
   CDFILIAL         VARCHAR2(4)   NOT NULL,
   CDCAIXA          VARCHAR2(3)   NOT NULL,
   DTABERCAIX       DATE          NOT NULL,
   NRSEQUMOVI       VARCHAR2(10)  NOT NULL,
   IDTPDOCSANG      VARCHAR2(1)   NOT NULL,
   CDFILIALNF       VARCHAR2(4)   NOT NULL,
   NRLANCTONF       VARCHAR2(10)  NOT NULL,
   NRORG            NUMBER DEFAULT 	 SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO          VARCHAR2(1)     DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_DOCSANGRIA CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO       DATE          NULL,
   DTULTATU         DATE          NULL,
   NRORGINCLUSAO    NUMBER        DEFAULT 1 NULL,
   CDOPERINCLUSAO   VARCHAR2(12)  DEFAULT '1' NULL,
   NRORGULTATU      NUMBER        DEFAULT 1 NULL,
   CDOPERULTATU     VARCHAR2(12)  DEFAULT '1',
      CONSTRAINT PK_DOCSANGRIA PRIMARY KEY (NRLANCTONF, CDFILIALNF)
)
/
CREATE INDEX FIS00743_DK ON DOCSANGRIA (CDFILIAL ASC, CDCAIXA ASC, DTABERCAIX ASC)
/
ALTER TABLE DOCSANGRIA
   ADD CONSTRAINT FKFIS00743 FOREIGN KEY (CDFILIAL, CDCAIXA, DTABERCAIX)
      REFERENCES TURCAIXA (CDFILIAL, CDCAIXA, DTABERCAIX) ON DELETE CASCADE
/
CREATE INDEX FIS00744_DK ON DOCSANGRIA (CDFILIALNF ASC, NRLANCTONF ASC)
/
ALTER TABLE DOCSANGRIA
   ADD CONSTRAINT FKFIS00744 FOREIGN KEY (CDFILIALNF, NRLANCTONF)
      REFERENCES NOTAFISCAL (CDFILIAL, NRLANCTONF ) ON DELETE CASCADE
/
CREATE INDEX FIS00745_DK ON DOCSANGRIA (CDFILIAL ASC, CDCAIXA ASC, DTABERCAIX ASC, NRSEQUMOVI ASC)
/
ALTER TABLE DOCSANGRIA
   ADD CONSTRAINT FKFIS00745 FOREIGN KEY (CDFILIAL, CDCAIXA, DTABERCAIX, NRSEQUMOVI)
      REFERENCES MOVCAIXA (CDFILIAL, CDCAIXA, DTABERCAIX, NRSEQUMOVI) ON DELETE CASCADE
/
ALTER TABLE GERAL_PAG ADD CDSERIEENTRSAG VARCHAR2(5)
/
ALTER TABLE GERAL_PAG ADD CDFORNECEDSAG VARCHAR2(21)
/
ALTER TABLE GERAL_PAG ADD CDTIPOOPERSAG VARCHAR2(2)
/
ALTER TABLE GERAL_PAG ADD CDTPCTPAGARSAG VARCHAR2(6)