/******************************************************************************/
/****              Generated by IBExpert 08/07/2022 09:05:50               ****/
/******************************************************************************/

/******************************************************************************/
/****     Following SET SQL DIALECT is just for the Database Comparer      ****/
/******************************************************************************/
SET SQL DIALECT 3;



/******************************************************************************/
/****                                Tables                                ****/
/******************************************************************************/


CREATE GENERATOR GTBCAIXABANCO_CONCILIACAO_HIST;

CREATE TABLE TBCAIXABANCO_CONCILIACAO_HIST (
    DATAHORA      TIMESTAMP DEFAULT 'NOW' NOT NULL,
    ID            INTEGER NOT NULL,
    DATA          DATE DEFAULT 'NOW',
    HISTORICO     VARCHAR(1000),
    BANCO_CONTA   INTEGER,
    BANCO_CODIGO  INTEGER,
    USUARIO_ID    INTEGER
);

/******************************************************************************/
/****                             Primary keys                             ****/
/******************************************************************************/

ALTER TABLE TBCAIXABANCO_CONCILIACAO_HIST ADD PRIMARY KEY (ID);


/******************************************************************************/
/****                               Indices                                ****/
/******************************************************************************/

CREATE INDEX ITBCAIXABANCO_CONC_HIST_01I ON TBCAIXABANCO_CONCILIACAO_HIST (BANCO_CODIGO);
CREATE INDEX ITBCAIXABANCO_CONC_HIST_02I ON TBCAIXABANCO_CONCILIACAO_HIST (BANCO_CONTA);
CREATE INDEX ITBCAIXABANCO_CONC_HIST_03I ON TBCAIXABANCO_CONCILIACAO_HIST (DATA);
CREATE INDEX ITBCAIXABANCO_CONC_HIST_04I ON TBCAIXABANCO_CONCILIACAO_HIST (USUARIO_ID);


/******************************************************************************/
/****                               Triggers                               ****/
/******************************************************************************/



SET TERM ^ ;



/******************************************************************************/
/****                         Triggers for tables                          ****/
/******************************************************************************/


/* Trigger: TTBCAIXABANCO_CONC_HIST_B0I */
CREATE OR ALTER TRIGGER TTBCAIXABANCO_CONC_HIST_B0I FOR TBCAIXABANCO_CONCILIACAO_HIST
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF(NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCAIXABANCO_CONCILIACAO_HIST,1);
END
^

SET TERM ; ^