Организация удаленного доступа к распределенным базам данных
Информация - Компьютеры, программирование
Другие материалы по предмету Компьютеры, программирование
D(PKey=new.PKey)AND(Code new.Code));
END ^
CREATE TRIGGER UslCat_BIH FOR UslCat
BEFORE INSERT POSITION 0
AS
BEGIN
DELETE FROM UslCat
=new.BegDate)AND(EndDate= new.BegDate) AND (EndDate <= new.EndDate) AND (PKey = new.PKey));
UPDATE UslCat
SET BegDate = new.EndDate
WHERE ((new.EndDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
UPDATE UslCat
SET EndDate = new.BegDate
WHERE ((new.BegDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END ^
CREATE TRIGGER UslCat_BDH FOR UslCat
BEFORE DELETE POSITION 0
AS
BEGIN
UPDATE UslCat
SET EndDate = old.EndDate
WHERE ((EndDate = old.BegDate) AND (PKey = old.PKey));
END ^
CREATE TABLE UslCatKeys (
Code INTEGER NOT NULL
);
ALTER TABLE UslCatKeys
ADD CONSTRAINT XPKUslCatKeys PRIMARY KEY (Code);
CREATE TABLE UslDivisions (
Code INTEGER NOT NULL,
Name DESCR_TYPE,
PKey INTEGER NOT NULL,
Parent INTEGER NOT NULL,
BegDate DATE_TYPE,
EndDate DATE_TYPE
);
CREATE INDEX XIEUslDivisionsname ON UslDivisions
(
Name
);
CREATE INDEX XIEUslDivisionsParent ON UslDivisions
(
Parent
);
ALTER TABLE UslDivisions
ADD CONSTRAINT XPKUslDivisions PRIMARY KEY (Code);
CREATE TRIGGER UslDivisions_BUH FOR UslDivisions
BEFORE UPDATE POSITION 0
AS
BEGIN
/* Изменение BegDate */
old.BegDate)THEN"> IF (new.BegDate <> old.BegDate) THEN
BEGIN
IF (new.BegDate < old.BegDate) THEN
BEGIN
/* Расширение BegDate */
UPDATE UslDivisions
SET EndDate = new.BegDate
WHERE ((new.BegDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END
ELSE
BEGIN
/* Сужение BegDate */
UPDATE UslDivisions
SET EndDate = new.BegDate
WHERE ((EndDate = old.BegDate) AND (PKey = new.PKey));
END
END
/* Изменение EndDate */
old.EndDate)THEN"> IF (new.EndDate <> old.EndDate) THEN
BEGIN
old.EndDate)THEN"> IF (new.EndDate > old.EndDate) THEN
BEGIN
/* Расширение EndDate */
UPDATE UslDivisions
SET BegDate = new.EndDate
WHERE ((new.EndDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END
ELSE
BEGIN
/* Сужение EndDate */
UPDATE UslDivisions
SET BegDate = new.EndDate
WHERE ((BegDate = old.EndDate) AND (PKey = new.PKey));
END
END
/* Сборка мусора */
DELETE FROM UslDivisions
=new.BegDate)AND(EndDate new.Code));
END ^
CREATE TRIGGER UslDivisions_BIH FOR UslDivisions
BEFORE INSERT POSITION 0
AS
BEGIN
DELETE FROM UslDivisions
=new.BegDate)AND(EndDate= new.BegDate) AND (EndDate <= new.EndDate) AND (PKey = new.PKey));
UPDATE UslDivisions
SET BegDate = new.EndDate
WHERE ((new.EndDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
UPDATE UslDivisions
SET EndDate = new.BegDate
WHERE ((new.BegDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END ^
CREATE TRIGGER UslDivisions_BDH FOR UslDivisions
BEFORE DELETE POSITION 0
AS
BEGIN
UPDATE UslDivisions
SET EndDate = old.EndDate
WHERE ((EndDate = old.BegDate) AND (PKey = old.PKey));
END ^
CREATE TABLE UslDivisionsKeys (
Code INTEGER NOT NULL
);
ALTER TABLE UslDivisionsKeys
ADD CONSTRAINT XPKUslDivisionsKeys PRIMARY KEY (Code);
CREATE TABLE UslLgots (
Code INTEGER NOT NULL,
Category INTEGER NOT NULL,
Property INTEGER,
Tax CURR_TYPE,
Usl INTEGER NOT NULL,
NachCoeff INTEGER NOT NULL,
Nalog INTEGER NOT NULL,
BegDate INTEGER NOT NULL,
Info INTEGER NOT NULL,
EndDate INTEGER NOT NULL
);
ALTER TABLE UslLgots
ADD CONSTRAINT XPKUslLgots PRIMARY KEY (Code);
CREATE TABLE UslProps (
Code INTEGER NOT NULL,
PKey INTEGER NOT NULL,
Tag INTEGER NOT NULL,
ValInteger INTEGER,
ValFloat FLOAT,
BegDate DATE_TYPE,
EndDate DATE_TYPE
);
ALTER TABLE UslProps
ADD CONSTRAINT XPKUslProps PRIMARY KEY (Code);
CREATE TRIGGER UslProps_BUH FOR UslProps
BEFORE UPDATE POSITION 0
AS
BEGIN
/* Изменение BegDate */
old.BegDate)THEN"> IF (new.BegDate <> old.BegDate) THEN
BEGIN
IF (new.BegDate < old.BegDate) THEN
BEGIN
/* Расширение BegDate */
UPDATE UslProps
SET EndDate = new.BegDate
WHERE ((new.BegDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END
ELSE
BEGIN
/* Сужение BegDate */
UPDATE UslProps
SET EndDate = new.BegDate
WHERE ((EndDate = old.BegDate) AND (PKey = new.PKey));
END
END
/* Изменение EndDate */
old.EndDate)THEN"> IF (new.EndDate <> old.EndDate) THEN
BEGIN
old.EndDate)THEN"> IF (new.EndDate > old.EndDate) THEN
BEGIN
/* Расширение EndDate */
UPDATE UslProps
SET BegDate = new.EndDate
WHERE ((new.EndDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));
END
ELSE
BEGIN
/* Сужение EndDate */
UPDATE UslProps
SET BegDate = new.EndDate
WHERE ((BegDate = old.EndDate) AND (PKey = new.PKey));
END
END
/* Сборка мусора */
DELETE FROM UslProps
=new.BegDate)AND(EndDate new.Code));
END ^
CREATE TRIGGER UslProps_BIH FOR UslProps
BEFORE INSERT POSITION 0
AS
BEGIN
DELETE FROM UslProps
=new.BegDate)AND(EndDate= new.BegDate) AND (EndDate <= new.EndDate) AND (PKey = new.PKey));