Входные параметры
Параметр | Тип | Описание |
---|---|---|
INVOICEID |
INTEGER |
|
STATE |
INTEGER |
|
COMMENT |
VARCHAR(250) |
|
FROMOWNERID |
INTEGER |
|
TOOWNERID |
INTEGER |
|
FROMCONTRACTID |
INTEGER |
|
TOCONTRACTID |
INTEGER |
|
REGDATE |
DATE |
|
STORAGEID |
INTEGER |
|
STORINGID |
INTEGER |
|
PACKID |
INTEGER |
|
NET |
INTEGER |
|
FROMQUALITYID |
INTEGER |
|
TOQUALITYID |
INTEGER |
|
TRANSPORTTYPEID |
INTEGER |
|
Выходные параметры
(Нет выходных параметров)
Описание
(Нет описания для процедуры INQUIRYUPDATE)
Определение
CREATE PROCEDURE INQUIRYUPDATE(
INVOICEID INTEGER,
STATE INTEGER,
COMMENT VARCHAR(250),
FROMOWNERID INTEGER,
TOOWNERID INTEGER,
FROMCONTRACTID INTEGER,
TOCONTRACTID INTEGER,
REGDATE DATE,
STORAGEID INTEGER,
STORINGID INTEGER,
PACKID INTEGER,
NET INTEGER,
FROMQUALITYID INTEGER,
TOQUALITYID INTEGER,
TRANSPORTTYPEID INTEGER)
AS
DECLARE VARIABLE FROMIT INTEGER;
DECLARE VARIABLE TOIT INTEGER;
DECLARE VARIABLE TEMP INTEGER;
begin
select first 1 it.inventoryid from it
where
(it.invoiceid = :INVOICEID or (it.invoiceid is null)) and it.operationid in (49,51)
order by it.inventoryid
into
:FROMIT;
select first 1 it.inventoryid from it
where
(it.invoiceid = :INVOICEID or (it.invoiceid is null)) and it.operationid in (50,53)
order by it.inventoryid desc
into
:toIT;
if (:STATE is null) then
state = 0;
update IT
set
it.COMMENT = :COMMENT,
it.CONTRACTID = :FROMCONTRACTID,
it.NET = :NET,
it.OWNERID = :FROMOWNERID,
it.providerid = :TOOWNERID,
it.REGDATE = :REGDATE,
it.invoiceid = :INVOICEID,
it.STATE = :STATE,
it.STORAGEID = :STORAGEID,
it.storingid = :STORINGID,
it.packid = :PACKID,
it.WEIGHT = :NET,
it.labqualityid = :FROMQUALITYID,
it.samplerqualityid = :FROMQUALITYID
where
it.inventoryid = :FROMIT;
if (:transporttypeid is not null) then
begin
select ittransport.inventoryid from ittransport where
ittransport.inventoryid = :FROMIT
into :TEMP;
if (:TEMP is null) then
insert into ittransport (ittransport.inventoryid, ittransport.transporttypeid)
values (:FROMIT, :transporttypeid);
else
update ittransport set
ittransport.transporttypeid = :transporttypeid
where
ittransport.inventoryid = :FROMIT; --,:TOIT);
end
update IT
set
it.COMMENT = :COMMENT,
it.CONTRACTID = :TOCONTRACTID,
it.NET = :NET*-1,
it.OWNERID = :TOOWNERID,
it.providerid = :FROMOWNERID,
it.invoiceid = :INVOICEID,
it.REGDATE = :REGDATE,
it.STATE = :STATE,
it.storingid = :STORINGID,
it.packid = :PACKID,
-- it.transporttypeid = :transporttypeid,
it.STORAGEID = :STORAGEID,
it.WEIGHT = :NET*-1,
it.labqualityid = :TOQUALITYID,
it.samplerqualityid = :TOQUALITYID
where
it.inventoryid = :TOIT;
end