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

FORM372

 

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

Параметр

Тип

Описание

DATE1

DATE

 

DATE2

DATE

 

STORAGEID

SMALLINT

 

PARTYID

INTEGER

 

PARTYDATE

DATE

 

 

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

Параметр

Тип

Описание

OUTCOMEBEFORE

NUMERIC(15,3)

 

CROPNAME

VARCHAR(20)

 

CLASSNAME

VARCHAR(20)

 

OUTCOMEAFTER

NUMERIC(15,3)

 

INCOMEAFTER

NUMERIC(15,3)

 

INCOMEBEFORE

NUMERIC(15,3)

 

OUTCOME

NUMERIC(15,3)

 

WOFFS

NUMERIC(15,3)

 

INCOME

NUMERIC(15,3)

 

 

Описание

(Нет описания для процедуры FORM372)

 

Определение

CREATE PROCEDURE FORM372(
    DATE1 DATE,
    DATE2 DATE,
    STORAGEID SMALLINT,
    PARTYID INTEGER,
    PARTYDATE DATE)
RETURNS (
    OUTCOMEBEFORE NUMERIC(15,3),
    CROPNAME VARCHAR(20),
    CLASSNAME VARCHAR(20),
    OUTCOMEAFTER NUMERIC(15,3),
    INCOMEAFTER NUMERIC(15,3),
    INCOMEBEFORE NUMERIC(15,3),
    OUTCOME NUMERIC(15,3),
    WOFFS NUMERIC(15,3),
    INCOME NUMERIC(15,3))
AS
declare variable WEIGHT integer;
declare variable OPERATIONID integer;
declare variable REGDATE date;
declare variable OPERATIONSUBTYPE smallint;
declare variable NET integer;
declare variable CLASSID integer;
BEGIN
  FOR
    select
      crop.cropname,
      class.classname,
      Q1.classid
    from  IT
      join GetWorkParties(:PARTYID,:PARTYDATE,null,null,:storageid)
        on (IT.PartyID = GetWorkParties.PartyID)
      left outer join quality Q1 on (IT.samplerqualityid = Q1.QUALITYID)
      left outer join Operation on (IT.operationid = operation.operationid)
      left outer join Crop on  (Q1.cropid = Crop.cropid)
      inner join Class on (Q1.classid = class.classid)
    where crop.croptypeid = 3 and it.net is not null and it.Storageid = :storageid
      and It.state >=0
      and it.parentid >=0
      and it.regdate <= :date2
    group by
      crop.cropname,
      class.classname,
      Q1.classid
    INTO :CROPNAME,
      :CLASSNAME,
      :CLASSID
  DO
  begin
     OUTCOMEBEFORE = 0;
     OUTCOMEAFTER = 0;
     INCOMEAFTER = 0;
     INCOMEBEFORE = 0;
     OUTCOME = 0;
     WOFFS = 0;
     INCOME = 0;
     for
       select
         It.net,
         operation.operationsubtype,
         IT.regdate,
         it.operationid,
         it.weight
       from  IT
         join GetWorkParties(:PARTYID,:PARTYDATE,null,null,:storageid)
           on (IT.PartyID = GetWorkParties.PartyID)
         left outer join quality Q1 on (IT.samplerqualityid = Q1.QUALITYID)
         LEFT OUTER JOIN Operation ON (IT.operationid = operation.operationid)
         Left outer join Crop on  (Q1.cropid = Crop.cropid)
       where it.regdate <= :date2
         and crop.croptypeid = 3
         and it.net is not null
         and it.Storageid = :storageid
         and Q1.classid = :classid
         and It.state >=0
         and it.parentid >=0
       into :NET,
         :OPERATIONSUBTYPE,
         :regdate,
         :operationid,
         :weight
    do
    begin
     if ((:regdate < :date1) and (:operationsubtype = 1)) then
       OUTCOMEBEFORE = :outcomebefore + :net;
     if ((:regdate <= :date2) and (:operationsubtype = 1)) then
       OUTCOMEAFTER = :OUTCOMEAFTER + :net;
     if ((:regdate <= :date2) and (:operationsubtype = 0)) then
       INCOMEAFTER = :INCOMEAFTER + :net;
     if ((:regdate < :date1) and (:operationsubtype = 0)) then
       INCOMEBEFORE = :INCOMEBEFORE + :net;
     if ((:regdate between :date1 and :date2) and (:operationsubtype = 1)) then
       OUTCOME = :OUTCOME + :net;
     if ((:regdate between :date1 and :date2) and (:operationsubtype = 0)) then
       INCOME = :INCOME + :net;
     if ((:regdate between :date1 and :date2) and (:operationid in (9,13,24,25))) then
       WOFFS = :WOFFS + :weight * -1;
    end
     OUTCOMEBEFORE = OUTCOMEBEFORE/1000;
     OUTCOMEAFTER =  OUTCOMEAFTER/1000;
     INCOMEAFTER = INCOMEAFTER/1000;
     INCOMEBEFORE = INCOMEBEFORE/1000;
     OUTCOME = OUTCOME/1000;
     WOFFS = WOFFS/1000;
     INCOME = INCOME/1000;
     
   if (((:INCOMEBEFORE - :OUTCOMEBEFORE) <> 0) or
     (:income <> 0) or
     (:outcome <> 0) or
     ((:INCOMEAFTER - :OUTCOMEAFTER) <> 0) or
     ((:woffs) <> 0)) then
   SUSPEND;
  end
END

 

     Previous topic Chapter index Next topic