/******************************************************************************/
/****              Generated by IBExpert 23/04/2021 17:25:07               ****/
/******************************************************************************/

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



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


CREATE GENERATOR GTBCLASSIFICACAO_CUSTO;

CREATE TABLE TBCLASSIFICACAO_CUSTO (
    ID                    INTEGER NOT NULL,
    CLASSIFICACAO_CODIGO  VARCHAR(10),
    VALOR                 NUMERIC(15,2),
    DATA                  DATE,
    TIPO                  VARCHAR(2)
);




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

ALTER TABLE TBCLASSIFICACAO_CUSTO ADD PRIMARY KEY (ID);


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

CREATE INDEX ITBCLASSIFICACAO_CUSTO_01 ON TBCLASSIFICACAO_CUSTO (DATA);
CREATE INDEX ITBCLASSIFICACAO_CUSTO_02 ON TBCLASSIFICACAO_CUSTO (CLASSIFICACAO_CODIGO);
CREATE INDEX ITBCLASSIFICACAO_CUSTO_03 ON TBCLASSIFICACAO_CUSTO (TIPO);


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



SET TERM ^ ;



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



/* Trigger: TTBCLASSIFICACAO_CUSTO_B0I */
CREATE OR ALTER TRIGGER TTBCLASSIFICACAO_CUSTO_B0I FOR TBCLASSIFICACAO_CUSTO
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gTBCLASSIFICACAO_CUSTO,1);
end
^

SET TERM ; ^



/******************************************************************************/
/****                         Fields descriptions                          ****/
/******************************************************************************/

COMMENT ON COLUMN TBCLASSIFICACAO_CUSTO.TIPO IS 
'CD
CI
D';



/******************************************************************************/
/****                              Privileges                              ****/
/******************************************************************************/


/* Privileges of users */
GRANT ALL ON TBCLASSIFICACAO_CUSTO TO HAROLDO WITH GRANT OPTION;
GRANT SELECT ON MON$ATTACHMENTS TO PUBLIC;
GRANT SELECT ON MON$CALL_STACK TO PUBLIC;
GRANT SELECT ON MON$CONTEXT_VARIABLES TO PUBLIC;
GRANT SELECT ON MON$DATABASE TO PUBLIC;
GRANT SELECT ON MON$IO_STATS TO PUBLIC;
GRANT SELECT ON MON$MEMORY_USAGE TO PUBLIC;
GRANT SELECT ON MON$RECORD_STATS TO PUBLIC;
GRANT SELECT ON MON$STATEMENTS TO PUBLIC;
GRANT SELECT ON MON$TABLE_STATS TO PUBLIC;
GRANT SELECT ON MON$TRANSACTIONS TO PUBLIC;