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

GETSESSION

 

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

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

 

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

Параметр

Тип

Описание

REGDATE

DATE

 

SESSION

INTEGER

 

 

Описание

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

 

Определение

CREATE PROCEDURE GETSESSION
RETURNS (
    REGDATE DATE,
    SESSION INTEGER)
AS
declare variable CURRENTTIME time;
declare variable SESSIONGROUP smallint;
declare variable MOVESTARTTIME time;
declare variable MOVEENDTIME time;
declare variable SESSIONCOUNT smallint;
begin
  CURRENTTIME = current_time;

  select count(SESSIONS.SESSIONID)
    from SESSIONS
  into :SESSIONCOUNT;

  if (:SESSIONCOUNT > 2) then
    SESSIONGROUP = mod((current_date - cast('01.01.2013' as date)), 4) + 1;

  select SESSIONS.SESSIONNUM, SESSIONS.MOVESTARTTIME, SESSIONS.MOVEENDTIME
    from SESSIONS
    where (((:CURRENTTIME between SESSIONS.STARTIME and SESSIONS.ENDTIME)
            or (:CURRENTTIME between SESSIONS.MOVESTARTTIME and SESSIONS.MOVEENDTIME))
           and (coalesce(SESSIONS.SESSIONGROUP,-1) = -1))
      or ((:CURRENTTIME between SESSIONS.STARTIME and SESSIONS.ENDTIME)
          and (SESSIONS.SESSIONGROUP = :SESSIONGROUP))
      or ((:CURRENTTIME between SESSIONS.MOVESTARTTIME and SESSIONS.MOVEENDTIME)
          and (SESSIONS.MOVESESSIONGROUP = :SESSIONGROUP))
  into :SESSION, :MOVESTARTTIME, :MOVEENDTIME;

  if ((CURRENTTIME >= MOVESTARTTIME) and (CURRENTTIME <= MOVEENDTIME)) then
    REGDATE = current_date - 1;
  else REGDATE = current_date;

  suspend;
end

 

     Previous topic Chapter index Next topic