SET SQL DIALECT 3; CREATE GENERATOR DK_GOODSPACK_ID; CREATE TABLE DK_GOODSPACK ( ID INTEGER NOT NULL, GDSID INTEGER NOT NULL, NAME VARCHAR(40) NOT NULL, QNT DOUBLE PRECISION NOT NULL, BARCODE VARCHAR(20) NOT NULL, DESCRIPTION VARCHAR(255) NOT NULL, USERNAME VARCHAR(20), LASTEDIT TIMESTAMP DEFAULT Current_TimeStamp ); /******************************************************************************/ /*** Primary Keys ***/ /******************************************************************************/ ALTER TABLE DK_GOODSPACK ADD CONSTRAINT DK_GOODSPACK_PK PRIMARY KEY (ID); /******************************************************************************/ /*** Foreign Keys ***/ /******************************************************************************/ ALTER TABLE DK_GOODSPACK ADD CONSTRAINT DK_GOODSPACK_FK FOREIGN KEY (GDSID) REFERENCES GOODS (ID); /******************************************************************************/ /*** Triggers ***/ /******************************************************************************/ SET TERM ^ ; /******************************************************************************/ /*** Triggers for tables ***/ /******************************************************************************/ /* Trigger: DK_GIFTCERTIFICATE_BI */ CREATE OR ALTER TRIGGER DK_GOODSPACK_BI FOR DK_GOODSPACK ACTIVE BEFORE INSERT POSITION 0 as begin if (New.ID is Null) then New.ID = Gen_ID(DK_GOODSPACK_ID, 1); end ^ CREATE OR ALTER TRIGGER DK_GOODSPACK_BU FOR DK_GOODSPACK ACTIVE BEFORE UPDATE POSITION 0 as begin New.LastEdit = Current_TimeStamp; end ^ SET TERM ; ^ /******************************************************************************/ /*** Descriptions ***/ /******************************************************************************/ COMMENT ON TABLE DK_GOODSPACK IS 'Упаковки товаров'; /******************************************************************************/ /*** Fields descriptions ***/ /******************************************************************************/ COMMENT ON COLUMN DK_GOODSPACK.GDSID IS 'ID товара'; COMMENT ON COLUMN DK_GOODSPACK.NAME IS 'Наименование'; COMMENT ON COLUMN DK_GOODSPACK.QNT IS 'Количество'; COMMENT ON COLUMN DK_GOODSPACK.BARCODE IS 'Штрих-код'; COMMENT ON COLUMN DK_GOODSPACK.DESCRIPTION IS 'Описание'; COMMENT ON COLUMN DK_GOODSPACK.USERNAME IS 'Имя пользователя'; COMMENT ON COLUMN DK_GOODSPACK.LASTEDIT IS 'Дата / время последней модификации записи'; /******************************************************************************/ /*** Privileges ***/ /******************************************************************************/