CREATE TABLE TBPERFIL_CLIENTE_DESCONTO (
    PERFIL         VARCHAR(10),
    CLIENTE_ID     INTEGER,
    ID             INTEGER NOT NULL,
    TIPO_DESCONTO  VARCHAR(1) DEFAULT 1,
    VALOR_DESCONTO NUMERIC(15,8)
);

CREATE GENERATOR GTBPERFIL_CLIENTE_DESCONTO;

ALTER TABLE TBPERFIL_CLIENTE_DESCONTO ADD PRIMARY KEY (ID);

CREATE OR ALTER TRIGGER TTBPERFIL_CLIENTE_DESCONTO_B0I FOR TBPERFIL_CLIENTE_DESCONTO
ACTIVE BEFORE INSERT POSITION 2
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBPERFIL_CLIENTE_DESCONTO,1);
END;
