declare

    column_exists exception;

    pragma exception_init (column_exists , -01430);

begin

    execute immediate 'ALTER TABLE FISCAL_F3 ADD (DAV NUMBER(13), CCE NUMBER(6))';

    exception when column_exists then null;

end;
/
declare

    column_exists exception;

    pragma exception_init (column_exists , -01430);

begin

    execute immediate 'ALTER TABLE FISCAL_P2 ADD (NCM VARCHAR2(7), CEST VARCHAR2(8))';

    exception when column_exists then null;

end;
/
declare

    table_exists exception;

    pragma exception_init (table_exists , -00955);

begin

  execute immediate

        'CREATE TABLE FISCAL_J1

        (

          FISCALJ1_ID NUMBER(15,0) NOT NULL ENABLE, 

          DATAEMISSAO VARCHAR2(8),
		  
		  SUBTOTAL NUMBER(14,0),
		  
		  DESCONTOSUBTOTAL NUMBER(13,0),
		  
		  INDDESCONTO VARCHAR2(1),
		  
		  ACRESCIMOSUBTOTAL NUMBER(13,0),
		  
		  INDACRESCIMOSUB VARCHAR2(1),
		  
		  TOTAL NUMBER(14,0),
		  
		  INDCANCELAMENTO VARCHAR2(1),
		  
		  CANCACRESCIMOSUB NUMBER(13,0),
		  
		  ORDEMACRESCIMO VARCHAR2(1),
		  
		  NOMECLIENTE VARCHAR2(40),
		  
		  CPFCNPJCLIENTE NUMBER(14,0),
		  
		  NUMNOTAFISCAL NUMBER(10,0),
		  
		  NUMSERIENOTAFISCAL VARCHAR2(3),
		  
		  CHNFE VARCHAR2(44),
		  
		  TIPODOCUMENTO NUMBER(1,0),

          ACTIVO NUMBER(1,0),

          FECMODIF DATE,

          USUARIO_ID NUMBER(7,0),

          CONSTRAINT FISCAL_J1_PK PRIMARY KEY (FISCALJ1_ID)

        ENABLE)';

    exception when table_exists then null;

end;
/
declare

    table_exists exception;

    pragma exception_init (table_exists , -00955);

begin

  execute immediate

        'CREATE TABLE FISCAL_J2

        (

          FISCALJ2_ID NUMBER(15,0) NOT NULL ENABLE, 

          DATAEMISSAO VARCHAR2(8),
		  
		  NUMITEM NUMBER(3,0),
		  
		  CODIGO VARCHAR2(14),
		  
		  DESCRICAO VARCHAR2(100),
		  
		  QUANTIDADE NUMBER(7,0),
		  
		  UNIDADE VARCHAR2(3),
		  
		  VALORUNITARIO NUMBER(8,0),
		  
		  DESCONTOITEM NUMBER(8,0),
		  
		  ACRESCIMOITEM NUMBER(8,0),
		  
		  TOTAL NUMBER(14,0),
		  
		  TOTALIZADOR VARCHAR2(7),
		  
		  DECIMAISQTD NUMBER(1,0),
		  
		  DECIMAISVALORUNT NUMBER(1,0),
		  
		  NUMNOTAFISCAL NUMBER(10,0),
		  
		  NUMSERIENOTAFISCAL VARCHAR2(3),
		  
		  CHNFE VARCHAR2(44),
		  
		  TIPODOCUMENTO NUMBER(1,0),

          ACTIVO NUMBER(1,0),

          FECMODIF DATE,

          USUARIO_ID NUMBER(7,0),

          CONSTRAINT FISCAL_J2_PK PRIMARY KEY (FISCALJ2_ID)

        ENABLE)';

    exception when table_exists then null;

end;