Входные параметры
Параметр | Тип | Описание |
---|---|---|
FROMINVENTORYID |
INTEGER |
|
TOINVENTORYID |
INTEGER |
|
COPYQ |
INTEGER |
|
Выходные параметры
(Нет выходных параметров)
Описание
(Нет описания для процедуры REGISTER_UPDATE)
Определение
CREATE PROCEDURE REGISTER_UPDATE(
FROMINVENTORYID INTEGER,
TOINVENTORYID INTEGER,
COPYQ INTEGER)
AS
declare variable PROVIDERID integer;
declare variable OWNERID integer;
declare variable CONTRACTID integer;
declare variable REGDATE date;
declare variable STORINGID integer;
declare variable STORAGEID integer;
declare variable PACKID integer;
declare variable REGISTERNUMBER varchar(10);
declare variable REGISTERID integer;
declare variable CROPID integer;
declare variable CLASSID integer;
declare variable SORTID integer;
declare variable FROMQUALITY integer;
declare variable TOQUALITY integer;
declare variable INVOICEID integer;
declare variable TOSAMPLERQUALITYID integer;
begin
select IT.PROVIDERID, IT.OWNERID, IT.CONTRACTID, IT.REGDATE, IT.STORINGID,
IT.STORAGEID, IT.PACKID, INVOICEREGISTERS.REGISTERNUMBER, IT.BUHQUALITYID
from IT
left join INVOICEREGISTERS on (INVOICEREGISTERS.INVOICEREGISTERID = IT.REGISTERID)
where (IT.INVENTORYID = :FROMINVENTORYID)
into :PROVIDERID, :OWNERID, :CONTRACTID, :REGDATE, :STORINGID, :STORAGEID,
:PACKID, :REGISTERNUMBER, :FROMQUALITY;
update IT
set IT.PROVIDERID = :PROVIDERID,
IT.OWNERID = :OWNERID,
IT.CONTRACTID = :CONTRACTID,
IT.REGDATE = :REGDATE,
IT.STORINGID = :STORINGID,
IT.STORAGEID = :STORAGEID,
IT.PACKID = :PACKID
where (IT.INVENTORYID = :TOINVENTORYID);
select INVOICEREGISTERS.INVOICEREGISTERID, IT.BUHQUALITYID, IT.SAMPLERQUALITYID
from IT
left join INVOICEREGISTERS on (INVOICEREGISTERS.INVOICEREGISTERID = IT.REGISTERID)
where IT.INVENTORYID = :TOINVENTORYID
into :REGISTERID, :TOQUALITY, :TOSAMPLERQUALITYID;
if ((:REGISTERID is null) and (not :REGISTERNUMBER is null)) then begin
REGISTERID = gen_id(INVOICEREGISTERS_IDGEN,1);
insert into INVOICEREGISTERS (INVOICEREGISTERS.INVOICEREGISTERID, INVOICEREGISTERS.REGISTERNUMBER)
values (:REGISTERID, :REGISTERNUMBER);
select IT.INVOICEID
from IT
where (IT.INVENTORYID = :TOINVENTORYID)
into :INVOICEID;
update IT
set IT.REGISTERID = :REGISTERID
where (IT.INVENTORYID = :TOINVENTORYID);
end
else
if (not :REGISTERNUMBER is null) then
update INVOICEREGISTERS
set INVOICEREGISTERS.REGISTERNUMBER = :REGISTERNUMBER
where (INVOICEREGISTERS.INVOICEREGISTERID = :REGISTERID);
if (:COPYQ = 1) then begin
select QUALITY.CROPID, QUALITY.CLASSID, QUALITY.SORTID
from QUALITY
where (QUALITY.QUALITYID = :FROMQUALITY)
into :CROPID, :CLASSID, :SORTID;
select QUALITY_COPY_ONLYDATA.RESULTQUALITYID
from QUALITY_COPY_ONLYDATA(:FROMQUALITY, :TOQUALITY)
into :TOQUALITY;
update QUALITY
set QUALITY.CROPID = :CROPID,
QUALITY.CLASSID = :CLASSID,
QUALITY.SORTID = :SORTID
where (QUALITY.QUALITYID = :TOQUALITY);
update QUALITY
set QUALITY.CROPID = :CROPID,
QUALITY.CLASSID = :CLASSID,
QUALITY.SORTID = :SORTID
where (QUALITY.QUALITYID = :TOSAMPLERQUALITYID);
/*
update IT
set IT.SAMPLERQUALITYID = :TOQUALITY
where (IT.INVENTORYID = :TOINVENTORYID);
*/
end
end