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

GETPARTYID_

 

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

Параметр

Тип

Описание

ISCURRENT

INTEGER

 

PARTYDATE

DATE

 

CROPID

INTEGER

 

CLASSID

INTEGER

 

STORAGEID

INTEGER

 

 

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

Параметр

Тип

Описание

PARTYID

INTEGER

 

PARTYNAME

VARCHAR(31)

 

BEGINDATE

DATE

 

ENDDATE

DATE

 

STATE

INTEGER

 

HARVESTINGYEAR

INTEGER

 

NEXTPARTYID

INTEGER

 

 

Описание

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

 

Определение

CREATE PROCEDURE GETPARTYID_(
    ISCURRENT INTEGER,
    PARTYDATE DATE,
    CROPID INTEGER,
    CLASSID INTEGER,
    STORAGEID INTEGER)
RETURNS (
    PARTYID INTEGER,
    PARTYNAME VARCHAR(31),
    BEGINDATE DATE,
    ENDDATE DATE,
    STATE INTEGER,
    HARVESTINGYEAR INTEGER,
    NEXTPARTYID INTEGER)
AS
declare variable PARTIES_ENDDATE date;
begin
  if (:ISCURRENT = 1) then
    for
      select PARTIES.PARTYID, PARTIES.PARTYNAME, PARTIES.BEGINDATE, PARTIES.ENDDATE,
          PARTIES.STATE, PARTIES.HARVESTINGYEAR
        from PARTIES
        where (PARTIES.STATE = 1)
          and ((PARTIES.STORAGEID = :STORAGEID) and (PARTIES.CROPID = :CROPID)
               and ((PARTIES.CLASSID = :CLASSID) or (PARTIES.CLASSID is null)))
      into :PARTYID, :PARTYNAME, :BEGINDATE, :ENDDATE, :STATE, :HARVESTINGYEAR
    do suspend;
  else begin
    if (:PARTYDATE > current_date) then
      PARTIES_ENDDATE = :PARTYDATE;
    else PARTIES_ENDDATE = current_date;

    for
      select PARTIES.PARTYID, PARTIES.PARTYNAME, PARTIES.BEGINDATE, PARTIES.ENDDATE,
          PARTIES.STATE, PARTIES.HARVESTINGYEAR, PARTIES.NEXTPARTYID
        from PARTIES
        where (:PARTYDATE between PARTIES.BEGINDATE and coalesce(PARTIES.ENDDATE,:PARTIES_ENDDATE))
          and ((PARTIES.STORAGEID = :STORAGEID) and (PARTIES.CROPID = :CROPID)
               and ((PARTIES.CLASSID = :CLASSID) or (PARTIES.CLASSID is null)))
      into :PARTYID, :PARTYNAME, :BEGINDATE, :ENDDATE, :STATE, :HARVESTINGYEAR, :NEXTPARTYID
    do suspend;
  end
end

 

     Previous topic Chapter index Next topic