"localhost:/firebird/data/ILICHEVSK2.FDB". Процедуры Previous topic Chapter index Next topic

WRTINGOFFSUPDATE

 

Входные параметры

Параметр

Тип

Описание

COMMENT

VARCHAR(255)

 

INVOICEID

INTEGER

 

LABQUALITYID

INTEGER

 

NET

INTEGER

 

OWNERID

INTEGER

 

CONTRACTID

INTEGER

 

REGDATE

DATE

 

STORAGEID

INTEGER

 

STATE

INTEGER

 

 

Выходные параметры

(Нет выходных параметров)

 

Описание

Обновление списания 3 кат.

 

Определение

CREATE PROCEDURE WRTINGOFFSUPDATE(
    COMMENT VARCHAR(255),
    INVOICEID INTEGER,
    LABQUALITYID INTEGER,
    NET INTEGER,
    OWNERID INTEGER,
    CONTRACTID INTEGER,
    REGDATE DATE,
    STORAGEID INTEGER,
    STATE INTEGER)
AS
DECLARE VARIABLE CROPID INTEGER;
DECLARE VARIABLE CLASSID INTEGER;
DECLARE VARIABLE QUALITYID INTEGER;
begin

update IT
set
  it.COMMENT = :COMMENT,
  it.CONTRACTID = :CONTRACTID,
  it.LABQUALITYID = :LABQUALITYID,
  it.NET = :NET,
  it.OWNERID = :OWNERID,
--  it.invoiceid = :INVOICEID,
  it.REGDATE = :REGDATE,
  it.SAMPLERQUALITYID = :LABQUALITYID,
  it.STATE = :STATE,
  it.STORAGEID = :STORAGEID,
  it.WEIGHT = :NET
where
--  (it.invoiceid = :INVOICEID or ((it.invoiceid is null))) and it.operationid = 22;
  it.invoiceid = :INVOICEID and it.operationid = 22;

if (:STORAGEID = 1) then
begin
  CROPID = 9;
  classid = 41;
end
else if (:STORAGEID = 13) then
begin
  CROPID = 16;
  classid = 64;
end

select it.labqualityid from it where it.invoiceid = :INVOICEID and it.operationid = 4
into :QUALITYID;

if (:QUALITYID is null) then
begin
  qualityid = gen_id(QUALITYIDGEN, 1);
  insert into quality(QUALITYID, cropid, classid)
  values
  (:QUALITYID, :CROPID, :CLASSID);
end
else
  update quality set quality.cropid = :CROPID, quality.classid = :CLASSID
  where quality.qualityid = :QUALITYID;

select * from QUALITY_COPY_ONLYDATA(:LABQUALITYID,:QUALITYID)
into
:QUALITYID;

update IT
set
  it.COMMENT = :COMMENT,
  it.CONTRACTID = :CONTRACTID,
  it.LABQUALITYID = :QUALITYID,
  it.NET = :NET,
  it.OWNERID = :OWNERID,
--  it.invoiceid = :INVOICEID,
  it.REGDATE = :REGDATE,
  it.SAMPLERQUALITYID = :QUALITYID,
  it.STATE = :STATE,
  it.STORAGEID = :STORAGEID,
  it.WEIGHT = :NET
where
--  (it.invoiceid = :INVOICEID or ((it.invoiceid is null))) and it.operationid = 4;
  it.invoiceid = :INVOICEID and it.operationid = 4;

end

 

     Previous topic Chapter index Next topic