CREATE TABLE DESPESA_UH (
ID_DESPESA_UH INTEGER NOT NULL PRIMARY KEY,
ID_P_S INTEGER,
QTD INTEGER,
VALOR_UNIT DECIMAL(15,2),
COMANDA INTEGER,
USUARIO VARCHAR(10),
DATA DATE,
HORA TIME,
PAGO CHAR(1),
ID_ENTRADA INTEGER,
TAXA DECIMAL(3,2),
DIARIA CHAR(1) DEFAULT 'N'
);

CREATE GENERATOR GEN_ID_DESPESA_UH ;

SET TERM ^;

CREATE TRIGGER TRIG_GEN_ID_DESPESA_UH FOR DESPESA_UH
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
   NEW.ID_DESPESA_UH = gen_id(GEN_ID_DESPESA_UH,1);
END
^

COMMIT WORK^
SET TERM;^
