- 11


);

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 */

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 */

IF (new.EndDate <> old.EndDate) THEN

BEGIN

IF (new.EndDate > old.EndDate) THEN

BEGIN

/* EndDate */