Допродажи (сопутствующие товары) к синхронизации

Материал из wiki.standart-n.ru
Версия от 18:06, 27 марта 2017; Olgav (обсуждение | вклад)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
ALTER TABLE ACCOMPANY
ADD D$SRVUPDDT DM_DATETIME;

ALTER TABLE ACCOMPANY
ADD D$UUID DM_UUID;

ALTER TABLE ACCOMPANY
ADD CONSTRAINT UNQ1_ACCOMPANY
UNIQUE (D$UUID);

SET SQL DIALECT 3;



SET TERM ^ ;



CREATE OR ALTER TRIGGER ACCOMPANY_BD_DISTR FOR ACCOMPANY
ACTIVE BEFORE DELETE POSITION 0
AS
begin
  update or insert into g$distribute (TABLENAME,UUID,SOPER,FROM_PROFILE_ID) 

values ('ACCOMPANY',old.d$uuid,2,null)
  matching (TABLENAME,UUID);
end
^

SET TERM ; ^

SET SQL DIALECT 3;



SET TERM ^ ;



CREATE OR ALTER TRIGGER ACCOMPANY_BU_DISTR FOR ACCOMPANY
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
  if (new.d$srvupddt=old.d$srvupddt) then
    update or insert into g$distribute (TABLENAME,UUID,SOPER,FROM_PROFILE_ID) 

values ('ACCOMPANY',new.d$uuid,1,null) matching (TABLENAME,UUID);
end
^

SET TERM ; ^


SET SQL DIALECT 3;



SET TERM ^ ;



CREATE OR ALTER TRIGGER ACCOMPANY_BI_DISTR FOR ACCOMPANY
ACTIVE BEFORE INSERT POSITION 0
AS
begin
  if (new.d$uuid is null) then
  begin
    new.d$uuid=UUID_TO_CHAR(GEN_UUID());
    new.d$srvupddt='2000-01-01';
    update or insert into g$distribute (TABLENAME,UUID,SOPER,FROM_PROFILE_ID) 

values ('ACCOMPANY',new.d$uuid,0,null) matching (TABLENAME,UUID);
  end
end
^

SET TERM ; ^