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

STORAGELOSS_GETRATE

 

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

Параметр

Тип

Описание

CROPID

INTEGER

*Культура

STORAGESTORINGTYPEID

INTEGER

*Тип хранения склада

DAYS

INTEGER

Количество дней хранения

 

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

Параметр

Тип

Описание

LOSSRATE

NUMERIC(5,3)

% убыли при хранении

 

Описание

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

 

Определение

CREATE PROCEDURE STORAGELOSS_GETRATE(
    CROPID INTEGER,
    STORAGESTORINGTYPEID INTEGER,
    DAYS INTEGER)
RETURNS (
    LOSSRATE NUMERIC(5,3))
AS
declare variable DAYMIN integer;
declare variable RATEMIN numeric(5,3);
declare variable DAYMAX integer;
declare variable RATEMAX numeric(5,3);
declare variable LOSSSETID integer;
begin
  select STORAGELOSSES.STORAGELOSSCROPID
      from STORAGELOSSES
    where (STORAGELOSSES.CROPID = :CROPID) and (STORAGELOSSES.STORAGESTORINGTYPEID = :STORAGESTORINGTYPEID)
  into :LOSSSETID;

  if (:LOSSSETID is not null) then begin
    select first 1 STORAGELOSSETS.STORINGDAYS, STORAGELOSSETS.LOSSRATE
        from STORAGELOSSETS
      where (STORAGELOSSETS.STORAGELOSSID = :LOSSSETID) and (STORAGELOSSETS.STORINGDAYS >= :DAYS)
      order by STORAGELOSSETS.STORINGDAYS
    into :DAYMAX, :RATEMAX;

    select first 1 STORAGELOSSETS.STORINGDAYS, STORAGELOSSETS.LOSSRATE
        from STORAGELOSSETS
      where (STORAGELOSSETS.STORAGELOSSID = :LOSSSETID) and (STORAGELOSSETS.STORINGDAYS < :DAYS)
      order by STORINGDAYS desc
    into :DAYMIN, :RATEMIN;

    if (:DAYMAX is null) then begin
      DAYMAX = :DAYMIN;
      RATEMAX = :RATEMIN;
    end
    else
      if (:DAYMIN is null) then begin
        DAYMIN = :DAYMAX;
        RATEMIN = :RATEMAX;
      end

    if ((DAYMAX - DAYS) < (DAYS - DAYMIN)) then
      LOSSRATE = :RATEMAX;
    else LOSSRATE = :RATEMIN;
  end

  suspend;

end

 

     Previous topic Chapter index Next topic