Описание
(Нет описания для триггера IT_SETQUALITYONSILAGE)
Определение
CREATE TRIGGER IT_SETQUALITYONSILAGE FOR IT
ACTIVE BEFORE INSERT OR UPDATE POSITION 0
AS
Declare Variable CropID integer;
Declare Variable ClassID integer;
Declare Variable SortID integer;
begin
if (new.SilageID is not null and old.SilageID is null
and new.SamplerQualityID is not null
and new.OperationID = 5
and exists (select * from ITTransport where InventoryID = new.InventoryID and TransportTypeID = 2)) then
begin
select CropID, ClassID, SortID
from Quality
where QualityID = new.SamplerQualityID
into :CropID, :ClassID, :SortID;
if (:CropID is null) Then
begin
select first 1 CropID --!!, ClassID, SortID
from silage
left join silagePacks on (SilagePacks.SilagePackID = Silage.SilagePackID)
left join Quality on (Quality.QualityID = silagePacks.QualityID)
where SilageID = new.SilageID
into :CropID; --!!, :ClassID, :SortID;
new.PartyID = null;
update Quality set CropID = :CropID --!!!, ClassID = :ClassID, SortID = :SortID
where QualityID = new.SamplerQualityID;
end
end
end