Описание
(Нет описания для триггера ILT$ITINSERT)
Определение
CREATE TRIGGER ILT$ITINSERT FOR IT
ACTIVE AFTER INSERT 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 (new.STATE <> -999) 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, 1);
for
select FIELDID, FIELDNAME
from ILT$FIELDS
where (ILT$FIELDS.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 (new.PARTYID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :PARTYIDID, new.PARTYID);
if (new.REGDATE is not null) then
insert into ilt$fielddate (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :REGDATEID, new.REGDATE);
if (new.OPERATIONID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :OPERATIONIDID, new.OPERATIONID);
if (new.INVOICEID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :INVOICEIDID, new.INVOICEID);
if (new.GROSS is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :GROSSID, new.GROSS);
if (new.TARE is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :TAREID, new.TARE);
if (new.NET is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :NETID, new.NET);
if (new.OWNERID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :OWNERIDID, new.OWNERID);
if (new.PROVIDERID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :PROVIDERIDID, new.PROVIDERID);
if (new.SAMPLERQUALITYID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :SAMPLERQUALITYIDID, new.SAMPLERQUALITYID);
if (new.LABQUALITYID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :LABQUALITYIDID, new.LABQUALITYID);
if (new.SILAGEID is not null)
then insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :SILAGEIDID, new.SILAGEID);
if (new.ROUTEID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :ROUTEIDID, new.ROUTEID);
if (new.STORAGEID is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :STORAGEIDID, new.STORAGEID);
if (new.STATE is not null) then
insert into ILT$FIELDINTEGER (TABLEOPERATIONID, FIELDID, FIELDVALUE)
values (:TABLEOPERATIONID, :STATEID, new.STATE);
end
end