CREATE GENERATOR GTBMAPEAMENTO_GRADE;

CREATE TABLE TBMAPEAMENTO_GRADE (
    ID              INTEGER NOT NULL,
    TAMANHO         VARCHAR(50),
    TAMANHO_ANTIGO  INTEGER,
    TAMANHO_NOVO    INTEGER,
    GRADE_ID        INTEGER
);




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

ALTER TABLE TBMAPEAMENTO_GRADE ADD CONSTRAINT PK_TBMAPEAMENTO_GRADE PRIMARY KEY (ID);


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



SET TERM ^ ;



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



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

SET TERM ; ^

ALTER TABLE TBMODELO ADD OLD_GRADE_CODIGO INTEGER;
ALTER TABLE TBCOR ADD COR_ANTIGA INTEGER
