Описание
(Нет описания для триггера ITTRANSPORT_COPYSTORAGEMOVE)
Определение
CREATE TRIGGER ITTRANSPORT_COPYSTORAGEMOVE FOR ITTRANSPORT
ACTIVE BEFORE UPDATE POSITION 0
as
declare variable OPERATIONID integer;
declare variable TARGETSTORAGEID integer;
declare variable STATE integer;
declare variable COPYINVENTORYID integer;
begin
select IT.OPERATIONID, IT.STATE, CLIENTS.STORAGEID
from IT
left join INVOICES on (INVOICES.INVOICEID = IT.INVOICEID)
left join CLIENTS on (CLIENTS.CLIENTID = INVOICES.SENDERID)
where (IT.INVENTORYID = new.INVENTORYID)
into :OPERATIONID, :STATE, :TARGETSTORAGEID;
if ((STATE = 200) or (OPERATIONID not in (1,5)) or (TARGETSTORAGEID is null)) then
exit;
COPYINVENTORYID = null;
select IT.INVENTORYID
from IT
where (IT.PARENTID = new.INVENTORYID)
into :COPYINVENTORYID;
if (COPYINVENTORYID is null) then begin
-- Вставка делается триггером в IT
end
else begin
update ITTRANSPORT
set CAPACITYWEIGHT = new.CAPACITYWEIGHT,
CAPACITYVOLUME = new.CAPACITYVOLUME,
SAMPLERINDATE = new.SAMPLERINDATE,
SAMPLERINTIME = new.SAMPLERINTIME,
SAMPLEROUTDATE = new.SAMPLEROUTDATE,
SAMPLEROUTTIME = new.SAMPLEROUTTIME,
TAREBYHAND = new.TAREBYHAND,
GROSSBYHAND = new.GROSSBYHAND,
LOADTIME = new.LOADTIME,
TRANSPORTTYPEID = new.TRANSPORTTYPEID,
TRANSPORTNUMBER = new.TRANSPORTNUMBER,
CHECKPOINTINTIME = new.CHECKPOINTINTIME,
CHECKPOINTOUTTIME = new.CHECKPOINTOUTTIME,
WEIGHTSESSION = new.WEIGHTSESSION,
INVOICEGROSS = new.INVOICEGROSS,
INVOICETARE = new.INVOICETARE,
INVOICENET = new.INVOICENET,
SENDERQUALITYID = new.SENDERQUALITYID,
OWNERFIELDID = new.OWNERFIELDID,
OWNERSTORAGEID = new.OWNERSTORAGEID,
BUNKERS = new.BUNKERS,
GRAINFIELDOUTTIME = new.GRAINFIELDOUTTIME,
CHECKPOINTSESSION = new.CHECKPOINTSESSION,
SAMPLERSESSION = new.SAMPLERSESSION
where (INVENTORYID = :COPYINVENTORYID);
end
end