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

AC_STORE_ILI_WEIGHT

 

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

Параметр

Тип

Описание

OWNERID

BIGINT

 

MINEXP

BIGINT

 

REGDATE

DATE

 

 

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

Параметр

Тип

Описание

ALLINCOME

INTEGER

 

ALLOUTCOME

INTEGER

 

SUMWEIGHT

INTEGER

 

DESCRIPT

VARCHAR(150)

 

 

Описание

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

 

Определение

CREATE PROCEDURE AC_STORE_ILI_WEIGHT(
    OWNERID BIGINT,
    MINEXP BIGINT,
    REGDATE DATE)
RETURNS (
    ALLINCOME INTEGER,
    ALLOUTCOME INTEGER,
    SUMWEIGHT INTEGER,
    DESCRIPT VARCHAR(150))
AS
declare variable R1 varchar(10);
declare variable INCOME integer;
declare variable OUTCOME integer;
declare variable OPERATIONNAME varchar(30);
declare variable T_DAY integer;
declare variable T_MONTH integer;
declare variable T_YEAR integer;
declare variable CURRENTNET integer;
begin
  ALLINCOME = 0;
  ALLOUTCOME = 0;
  SUMWEIGHT = 0;
  DESCRIPT = '';

  for
    select
        coalesce(case
                   when ((EAI.OPERATIONID = 1) or ((EAI.OPERATIONID = 17) and (EA.OWNERID = :OWNERID))) then
                     EAI.TESTWEIGHT
                 end, 0) INCOME,
        coalesce(case
                   when ((EAI.OPERATIONID = 17) and (EA.OWNERID <> :OWNERID)) then
                     EAI.TESTWEIGHT
                   when (EAI.OPERATIONID = 5) then
                     EAI.TESTWEIGHT
                   when (EAI.OPERATIONID = 22) then
                     -EAI.WEIGHT
                   else
                     case
                       when (EAI.OPERATIONID <> 1) then
                         -EAI.TESTWEIGHT
                     end
                 end,0) OUTCOME,
        coalesce(case
                   when ((EAI.OPERATIONID = 5) or ((EAI.OPERATIONID = 17) and (EA.OWNERID <> :OWNERID))) then
                     -EAI.TESTWEIGHT
                   when (EAI.OPERATIONID = 22) then
                     EAI.WEIGHT
                   else EAI.TESTWEIGHT
                 end,0) SUMWEIGHT,
        OPERATION.OPERATIONNAME
      from EXPORTACTITEMS EAI
        join EXPORTACTS EA on ((EA.EXPORTACTID = EAI.EXPORTACTID) and (EA.STATE <> 10))
        join OPERATION on (OPERATION.OPERATIONID = EAI.OPERATIONID)
        left join IT on ((IT.INVENTORYID = EAI.INVENTORYID) and (IT.STATE in (0,1,-20)))
      where ((EAI.EXPORTACTITEMID = :MINEXP) or (EAI.PARENTITEMID = :MINEXP))
        and (((EAI.OPERATIONID in (22,70)) and (IT.REGDATE = :REGDATE))
             or ((EAI.OPERATIONID not in (22,70)) and (EA.REGDATE = :REGDATE)))
    into :ALLINCOME, :ALLOUTCOME, :CURRENTNET, :OPERATIONNAME

  do begin
    DESCRIPT = :OPERATIONNAME;
    SUMWEIGHT = :CURRENTNET;

    T_DAY = extract(day from :REGDATE);
    T_MONTH = extract(month from :REGDATE);

    if (T_DAY < 10) then
      R1 = '0' || T_DAY;
    else R1 = T_DAY;

    if (T_MONTH < 10) then
      R1 = R1 || '.0' || T_MONTH;
    else R1 = R1 || '.' || T_MONTH;

    DESCRIPT = DESCRIPT || ' от ' || R1;

    suspend;
  end
end

 

     Previous topic Chapter index Next topic