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

SILAGEPACKS_DECREASE_WEIGHT

 

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

Параметр

Тип

Описание

SILAGEPACKID

INTEGER

 

DELTAWEIGHT

INTEGER

 

INVENTORYID

INTEGER

 

CLASSID

INTEGER

 

 

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

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

 

Описание

Уменьшение веса силос-пакета при отргузке на мельницу

 

Определение

CREATE PROCEDURE SILAGEPACKS_DECREASE_WEIGHT(
    SILAGEPACKID INTEGER,
    DELTAWEIGHT INTEGER,
    INVENTORYID INTEGER,
    CLASSID INTEGER)
AS
declare variable silageid integer;
declare variable weight integer;
declare variable qualityid integer;
declare variable silagequalityid integer;
declare variable oldweight integer;
declare variable adeltaweight integer;
declare variable countquality integer;
begin
  adeltaweight = :DELTAWEIGHT;
  for
    select silageid, weight from silage where silagepackid = :silagepackid
    into :silageid, :weight
  do begin
    if ((:adeltaweight > 0) and (not(:weight is null))) then begin
      if (:adeltaweight > :weight) then begin
        update silage set weight = weight - :Weight, inventoryid = :INVENTORYID
        where silageid = :silageid;
        adeltaweight = :adeltaweight - :weight;
      end
      else begin
        update silage set weight = weight - :adeltaweight, inventoryid = :INVENTORYID
        where silageid = :silageid;
        adeltaweight = 0;
      end
    end
  end
------------------------------------
  select silagequalityid from silagepacks where silagepackid = :silagepackid

  into :silagequalityid;

  select sum(weight), count(silagequalityid) from silagequality where silagequalityid = :silagequalityid
  into :oldweight, :countquality;

  if (:countquality > 1) then begin
--    update silagequality set weight = weight - :aweight
--    where silagequalityid = :silagequalityid;
--  end
--  else begin
    for
      select silagequality.qualityid, weight from silagequality
        left join quality on (quality.qualityid = silagequality.qualityid)
      where silagequalityid = :silagequalityid
        and quality.classid = :classID
      into :qualityid, :weight
    do begin
      update silagequality set weight = (:oldweight - :DELTAWEIGHT) * :weight / :oldweight
      where silagequalityid = :silagequalityid and qualityid = :qualityid;
    end
  end
-------------------------------------
END

 

     Previous topic Chapter index Next topic