Описание
(Нет описания для триггера ILT$ITUPDATE)
Определение
CREATE TRIGGER ILT$ITUPDATE FOR IT
ACTIVE AFTER UPDATE POSITION 1000
as
declare variable TABLEOPERATIONID integer;
declare variable TABLEID integer;
declare variable FIELDID integer;
declare variable FIELDNAME char(31);
declare variable PARTYIDID integer;
declare variable REGDATEID integer;
declare variable OPERATIONIDID integer;
declare variable INVOICEIDID integer;
declare variable GROSSID integer;
declare variable TAREID integer;
declare variable NETID integer;
declare variable OWNERIDID integer;
declare variable PROVIDERIDID integer;
declare variable SAMPLERQUALITYIDID integer;
declare variable LABQUALITYIDID integer;
declare variable SILAGEIDID integer;
declare variable ROUTEIDID integer;
declare variable STORAGEIDID integer;
declare variable STATEID integer;
begin
if (old.STATE <> -999) then
if ((((old.PARTYID is null) and (new.PARTYID is not null))
or ((old.PARTYID is not null) and (new.PARTYID is null))
or ((old.PARTYID is not null) and (new.PARTYID is not null) and (old.PARTYID <> new.PARTYID)))
or (((old.REGDATE is null) and (new.REGDATE is not null))
or ((old.REGDATE is not null) and (new.REGDATE is null))
or ((old.REGDATE is not null) and (new.REGDATE is not null) and (old.REGDATE <> new.REGDATE)))
or (((old.OPERATIONID is null) and (new.OPERATIONID is not null))
or ((old.OPERATIONID is not null) and (new.OPERATIONID is null))
or ((old.OPERATIONID is not null) and (new.OPERATIONID is not null) and (old.OPERATIONID <> new.OPERATIONID)))
or (((old.INVOICEID is null) and (new.INVOICEID is not null))
or ((old.INVOICEID is not null) and (new.INVOICEID is null))
or ((old.INVOICEID is not null) and (new.INVOICEID is not null) and (old.INVOICEID <> new.INVOICEID)))
or (((old.GROSS is null) and (new.GROSS is not null))
or ((old.GROSS is not null) and (new.GROSS is null))
or ((old.GROSS is not null) and (new.GROSS is not null) and (old.GROSS <> new.GROSS)))
or (((old.TARE is null) and (new.TARE is not null))
or ((old.TARE is not null) and (new.TARE is null))
or ((old.TARE is not null) and (new.TARE is not null) and (old.TARE <> new.TARE)))
or (((old.NET is null) and (new.NET is not null))
or ((old.NET is not null) and (new.NET is null))
or ((old.NET is not null) and (new.NET is not null) and (old.NET <> new.NET)))
or (((old.OWNERID is null) and (new.OWNERID is not null))
or ((old.OWNERID is not null) and (new.OWNERID is null))
or ((old.OWNERID is not null) and (new.OWNERID is not null) and (old.OWNERID <> new.OWNERID)))
or (((old.PROVIDERID is null) and (new.PROVIDERID is not null))
or ((old.PROVIDERID is not null) and (new.PROVIDERID is null))
or ((old.PROVIDERID is not null) and (new.PROVIDERID is not null) and (old.PROVIDERID <> new.PROVIDERID)))
or (((old.SAMPLERQUALITYID is null) and (new.SAMPLERQUALITYID is not null))
or ((old.SAMPLERQUALITYID is not null) and (new.SAMPLERQUALITYID is null))
or ((old.SAMPLERQUALITYID is not null) and (new.SAMPLERQUALITYID is not null) and (old.SAMPLERQUALITYID <> new.SAMPLERQUALITYID)))
or (((old.LABQUALITYID is null) and (new.LABQUALITYID is not null))
or ((old.LABQUALITYID is not null) and (new.LABQUALITYID is null))
or ((old.LABQUALITYID is not null) and (new.LABQUALITYID is not null) and (old.LABQUALITYID <> new.LABQUALITYID)))
or (((old.SILAGEID is null) and (new.SILAGEID is not null))
or ((old.SILAGEID is not null) and (new.SILAGEID is null))
or ((old.SILAGEID is not null) and (new.SILAGEID is not null) and (old.SILAGEID <> new.SILAGEID)))
or (((old.ROUTEID is null) and (new.ROUTEID is not null))
or ((old.ROUTEID is not null) and (new.ROUTEID is null))
or ((old.ROUTEID is not null) and (new.ROUTEID is not null) and (old.ROUTEID <> new.ROUTEID)))
or (((old.STORAGEID is null) and (new.STORAGEID is not null))
or ((old.STORAGEID is not null) and (new.STORAGEID is null))
or ((old.STORAGEID is not null) and (new.STORAGEID is not null) and (old.STORAGEID <> new.STORAGEID)))
or (((old.STATE is null) and (new.STATE is not null))
or ((old.STATE is not null) and (new.STATE is null))
or ((old.STATE is not null) and (new.STATE is not null) and (old.STATE <> new.STATE)))
) then begin
TABLEOPERATIONID = gen_ID(GEN_ILT$TABLEOPERATION_ID,1);
select TABLEID
from ILT$TABLES
where (ILT$TABLES.TABLENAME = 'IT')
into :TABLEID;
insert into ILT$TABLEOPERATION (TABLEOPERATIONID, TABLEID, RECORDID, OPERATIONID)
values (:TABLEOPERATIONID, :TABLEID, new.INVENTORYID, 2);
for
select FIELDID, FIELDNAME
from ILT$FIELDS
where (TABLEID = :TABLEID)
into :FIELDID, :FIELDNAME
do begin
if (:FIELDNAME = 'PARTYID') then
PARTYIDID = :FIELDID;
else
if (:FIELDNAME = 'REGDATE') then
REGDATEID = :FIELDID;
else
if (:FIELDNAME = 'OPERATIONID') then
OPERATIONIDID = :FIELDID;
else
if (:FIELDNAME = 'INVOICEID') then
INVOICEIDID = :FIELDID;
else
if (:FIELDNAME = 'GROSS') then
GROSSID = :FIELDID;
else
if (:FIELDNAME = 'TARE') then
TAREID = :FIELDID;
else
if (:FIELDNAME = 'NET') then
NETID = :FIELDID;
else
if (:FIELDNAME = 'OWNERID') then
OWNERIDID = :FIELDID;
else
if (:FIELDNAME = 'PROVIDERID') then
PROVIDERIDID = :FIELDID;
else
if (:FIELDNAME = 'SAMPLERQUALITYID') then
SAMPLERQUALITYIDID = :FIELDID;
else
if (:FIELDNAME = 'LABQUALITYID') then
LABQUALITYIDID = :FIELDID;
else
if (:FIELDNAME = 'SILAGEID') then
SILAGEIDID = :FIELDID;
else
if (:FIELDNAME = 'ROUTEID') then
ROUTEIDID = :FIELDID;
else
if (:FIELDNAME = 'STORAGEID') then
STORAGEIDID = :FIELDID;
else
if (:FIELDNAME = 'STATE') then
STATEID = :FIELDID;
end
if (((old.PARTYID is null) and (new.PARTYID is not null))
or ((old.PARTYID is not null) and (new.PARTYID is null))
or ((old.PARTYID is not null) and (new.PARTYID is not null) and (old.PARTYID <> new.PARTYID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :PARTYIDID, new.PARTYID);
if (((old.REGDATE is null) and (new.REGDATE is not null))
or ((old.REGDATE is not null) and (new.REGDATE is null))
or ((old.REGDATE is not null) and (new.REGDATE is not null) and (old.REGDATE <> new.REGDATE))) then
insert into ilt$fielddate (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :REGDATEID, new.REGDATE);
if (((old.OPERATIONID is null) and (new.OPERATIONID is not null))
or ((old.OPERATIONID is not null) and (new.OPERATIONID is null))
or ((old.OPERATIONID is not null) and (new.OPERATIONID is not null) and (old.OPERATIONID <> new.OPERATIONID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :OPERATIONIDID, new.OPERATIONID);
if (((old.INVOICEID is null) and (new.INVOICEID is not null))
or ((old.INVOICEID is not null) and (new.INVOICEID is null))
or ((old.INVOICEID is not null) and (new.INVOICEID is not null) and (old.INVOICEID <> new.INVOICEID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :INVOICEIDID, new.INVOICEID);
if (((old.GROSS is null) and (new.GROSS is not null))
or ((old.GROSS is not null) and (new.GROSS is null))
or ((old.GROSS is not null) and (new.GROSS is not null) and (old.GROSS <> new.GROSS))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :GROSSID, new.GROSS);
if (((old.TARE is null) and (new.TARE is not null))
or ((old.TARE is not null) and (new.TARE is null))
or ((old.TARE is not null) and (new.TARE is not null) and (old.TARE <> new.TARE))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :TAREID, new.TARE);
if (((old.NET is null) and (new.NET is not null))
or ((old.NET is not null) and (new.NET is null))
or ((old.NET is not null) and (new.NET is not null) and (old.NET <> new.NET))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :NETID, new.NET);
if (((old.OWNERID is null) and (new.OWNERID is not null))
or ((old.OWNERID is not null) and (new.OWNERID is null))
or ((old.OWNERID is not null) and (new.OWNERID is not null) and (old.OWNERID <> new.OWNERID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :OWNERIDID, new.OWNERID);
if (((old.PROVIDERID is null) and (new.PROVIDERID is not null))
or ((old.PROVIDERID is not null) and (new.PROVIDERID is null))
or ((old.PROVIDERID is not null) and (new.PROVIDERID is not null) and (old.PROVIDERID <> new.PROVIDERID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :PROVIDERIDID, new.PROVIDERID);
if (((old.SAMPLERQUALITYID is null) and (new.SAMPLERQUALITYID is not null))
or ((old.SAMPLERQUALITYID is not null) and (new.SAMPLERQUALITYID is null))
or ((old.SAMPLERQUALITYID is not null) and (new.SAMPLERQUALITYID is not null) and (old.SAMPLERQUALITYID <> new.SAMPLERQUALITYID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :SAMPLERQUALITYIDID, new.SAMPLERQUALITYID);
if (((old.LABQUALITYID is null) and (new.LABQUALITYID is not null))
or ((old.LABQUALITYID is not null) and (new.LABQUALITYID is null))
or ((old.LABQUALITYID is not null) and (new.LABQUALITYID is not null) and (old.LABQUALITYID <> new.LABQUALITYID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :LABQUALITYIDID, new.LABQUALITYID);
if (((old.SILAGEID is null) and (new.SILAGEID is not null))
or ((old.SILAGEID is not null) and (new.SILAGEID is null))
or ((old.SILAGEID is not null) and (new.SILAGEID is not null) and (old.SILAGEID <> new.SILAGEID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :SILAGEIDID, new.SILAGEID);
if (((old.ROUTEID is null) and (new.ROUTEID is not null))
or ((old.ROUTEID is not null) and (new.ROUTEID is null))
or ((old.ROUTEID is not null) and (new.ROUTEID is not null) and (old.ROUTEID <> new.ROUTEID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :ROUTEIDID, new.ROUTEID);
if (((old.STORAGEID is null) and (new.STORAGEID is not null))
or ((old.STORAGEID is not null) and (new.STORAGEID is null))
or ((old.STORAGEID is not null) and (new.STORAGEID is not null) and (old.STORAGEID <> new.STORAGEID))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :STORAGEIDID, new.STORAGEID);
if (((old.STATE is null) and (new.STATE is not null))
or ((old.STATE is not null) and (new.STATE is null))
or ((old.STATE is not null) and (new.STATE is not null) and (old.STATE <> new.STATE))) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :STATEID, new.STATE);
end
end