CREATE TABLE ESCALA_DET (
ID_ESCALA_DET INTEGER NOT NULL PRIMARY KEY,
ID_ESCALA INTEGER,
ID_FUNCIONARIO INTEGER,
DATA_INICIO DATE,
HORA_INICIO TIME,
DATA_TERMINO DATE,
HORA_TERMINO TIME
);

CREATE GENERATOR GEN_ID_ESCALA_DET ;

SET TERM ^;

CREATE TRIGGER TRIG_GEN_ID_ESCALA_DET FOR ESCALA_DET
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
   NEW.ID_ESCALA_DET = gen_id(GEN_ID_ESCALA_DET,1);
END
^

COMMIT WORK^
SET TERM;^

UPDATE PARAMETROS SET SCRIPT = '101';
