SET SQL DIALECT 3;
CREATE DATABASE 'option.fdb' USER 'SYSDBA' PASSWORD  'masterkey' PAGE_SIZE = 16384 DEFAULT CHARACTER SET WIN1251;
CREATE TABLE lines (ID INTEGER,LINE INTEGER,NAME VARCHAR(255));

CREATE GENERATOR GEN_LINE_ID;
SET GENERATOR GEN_LINE_ID TO 0;

set term !! ;
CREATE TRIGGER TGEN_LINE_ID FOR lines
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_LINE_ID, 1);
END!!
set term ; !!

INSERT INTO lines(LINE) VALUES(0) RETURNING id;
INSERT INTO lines(LINE) VALUES(0) RETURNING id;

commit;