Скрипт дополнений к ЕГАИС
Материал из wiki.standart-n.ru
set term ^; CREATE TABLE EGAIS_PRODUCERS ( ID DM_TEXT NOT NULL /* DM_TEXT = VARCHAR(250) */, INN DM_TEXT /* DM_TEXT = VARCHAR(250) */, KPP DM_TEXT /* DM_TEXT = VARCHAR(250) */, FULLNAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, SHORTNAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, COUNTRY DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, POSTINDEX DM_TEXT /* DM_TEXT = VARCHAR(250) */, REGIONCODE DM_TEXT /* DM_TEXT = VARCHAR(250) */, DESCRIPTION DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, CITY DM_TEXT /* DM_TEXT = VARCHAR(250) */, STREET DM_TEXT /* DM_TEXT = VARCHAR(250) */ );^ CREATE UNIQUE INDEX EGAIS_PRODUCERS_IDX1 ON EGAIS_PRODUCERS (ID);^ create generator GEN_EGAIS_SHOP_ID; ^ create table EGAIS_SHOP ( ID integer not null, PART_ID DM_ID_NULL /* DM_ID_NULL = bigint */, SNAME DM_TEXT1024 /* DM_TEXT1024 = varchar (1024) */, QUANT DM_DOUBLE /* DM_DOUBLE = double precision */, EGAIS_QUANT DM_DOUBLE /* DM_DOUBLE = double precision */, ALCCODE DM_TEXT1024 /* DM_TEXT1024 = varchar (1024) */, UNITTYPE DM_TEXT /* DM_TEXT = varchar (250) */, ALCVOLUME DM_DOUBLE /* DM_DOUBLE = double precision */, PRODUCTVCODE DM_STATUS /* DM_STATUS = integer */, PRODUCER_ID DM_TEXT /* DM_TEXT = varchar (250) */); ^ create or alter trigger EGAIS_SHOP_BI for EGAIS_SHOP active before insert position 0 as begin if (new.ID is null) then new.ID = gen_id(GEN_EGAIS_SHOP_ID, 1); end^ create or alter view VW_WARESHOP ( ID, PART_ID, SNAME, QUANT, EGAIS_QUANT, ALCCODE, UNITTYPE, ALCVOLUME, PRODUCTVCODE, PRODUCER_ID) as select ID, PART_ID, SNAME, QUANT, EGAIS_QUANT, ALCCODE, UNITTYPE, ALCVOLUME, PRODUCTVCODE, PRODUCER_ID from EGAIS_SHOP; ^ set term; ^ /******************************************************************************/ /*** Generated by IBExpert 27.09.2016 17:09:58 ***/ /******************************************************************************/ /******************************************************************************/ /*** Following SET SQL DIALECT is just for the Database Comparer ***/ /******************************************************************************/ SET SQL DIALECT 3; /******************************************************************************/ /*** Tables ***/ /******************************************************************************/ CREATE GENERATOR GEN_EGAIS_SKLAD_ID; CREATE TABLE EGAIS_SKLAD ( ID DM_ID NOT NULL /* DM_ID = BIGINT */, QUANTITY DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, INFORMAREGID DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, INFORMBREGID DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, FULLNAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, ALCCODE DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, CAPACITY DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, ALCVOLUME DM_DOUBLE /* DM_DOUBLE = DOUBLE PRECISION */, PRODUCTVCODE DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_CLIENTREGID DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_INN DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_KPP DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_FULLNAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_SHORTNAME DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_COUNTRY DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_REGIONCODE DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, PRODUCER_DESCRIPTION DM_TEXT1024 /* DM_TEXT1024 = VARCHAR(1024) */, INSERTDT DM_DATETIME /* DM_DATETIME = TIMESTAMP */ ); /******************************************************************************/ /*** Triggers ***/ /******************************************************************************/ SET TERM ^ ; /******************************************************************************/ /*** Triggers for tables ***/ /******************************************************************************/ /* Trigger: EGAIS_SKLAD_BI */ CREATE OR ALTER TRIGGER EGAIS_SKLAD_BI FOR EGAIS_SKLAD ACTIVE BEFORE INSERT POSITION 0 as begin if (new.id is null) then new.id = gen_id(gen_egais_sklad_id,1); if (new.insertdt is null) then new.insertdt = 'now'; end ^ SET TERM ; ^ /******************************************************************************/ /*** Privileges ***/ /******************************************************************************/