- 12


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

WHERE ((BegDate >= new.BegDate) AND (EndDate <= new.EndDate) AND (PKey = new.PKey) AND (Code <> new.Code));

END ^

CREATE TRIGGER UslProps_BIH FOR UslProps

BEFORE INSERT POSITION 0

AS

BEGIN

DELETE FROM UslProps

WHERE ((BegDate >= new.BegDate) AND (EndDate <= new.EndDate) AND (PKey = new.PKey));

UPDATE UslProps

SET BegDate = new.EndDate

WHERE ((new.EndDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));

UPDATE UslProps

SET EndDate = new.BegDate

WHERE ((new.BegDate BETWEEN BegDate AND EndDate) AND (PKey = new.PKey));

END ^

CREATE TRIGGER UslProps_BDH FOR UslProps

BEFORE DELETE POSITION 0

AS

BEGIN

UPDATE UslProps

SET EndDate = old.EndDate

WHERE ((EndDate = old.BegDate) AND (PKey = old.PKey));

END ^

CREATE TABLE UslPropsKeys (

Code INTEGER NOT NULL

);

ALTER TABLE UslPropsKeys

ADD CONSTRAINT XPKUslPropsKeys PRIMARY KEY (Code);

CREATE TABLE Usls (

Code INTEGER NOT NULL,

PKey INTEGER NOT NULL,

Division INTEGER NOT NULL,

UslType INTEGER NOT NULL,

Name CHAR(64) NOT NULL,

BegDate DATE_TYPE,

EndDate DATE_TYPE

);

CREATE INDEX XIEUslsName ON Usls