IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Sel_SessionInfo')
  DROP PROCEDURE [dbo].[up_Sel_SessionInfo]
GO
CREATE PROCEDURE [dbo].[up_Sel_SessionInfo]
  @RI integer
AS
  SELECT TOP 1
         convert(integer,1)			 AS IsValid
       , (SELECT count(*) AS Result FROM [dbo].[itcview_SessionActivity] WHERE [InactiveSince] < 30) AS ConnectCnt
       , -1 AS ConnectMax
       , (SELECT (sum([size]) * 8 ) / 1024 FROM sysfiles WHERE [groupid] <> 0)  AS CurDBSize
       , ISNULL( (select OptDataI from Optionen Where OptId = '20004'), 1700 ) AS MaxDBSize
       , convert(varchar(80),RTRIM(@@SERVERNAME) )  AS ServerName 
       , convert(varchar(80),RTRIM(@@SERVICENAME) ) AS InstanceName
       , convert(varchar(80),RTRIM(DB_NAME()))      AS DatabaseName
       , convert(varchar(80),RTRIM(sl.[name]))      AS LoginName
       , convert(varchar(80),RTRIM(CURRENT_USER))   AS UserName
       , convert(varchar(80),RTRIM(sp.[hostname]))  AS WorkStation
  FROM       master.dbo.syslogins sl
  INNER JOIN master.dbo.sysprocesses sp 
     ON sp.[sid] = sl.[sid] AND sp.[spid] = @@SPID
GO


IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Upd_SessionInfo')
  DROP PROCEDURE [dbo].[up_Upd_SessionInfo]
GO
CREATE PROCEDURE [dbo].[up_Upd_SessionInfo]
  @RI integer
 ,@Parm_IsValid integer
 ,@Parm_ConnectCnt integer
 ,@Parm_ConnectMax integer
 ,@Parm_CurDBSize integer
 ,@Parm_MaxDBSize integer
 ,@Parm_ServerName char(80)
 ,@Parm_InstanceName char(80)
 ,@Parm_DatabaseName char(80)
 ,@Parm_LoginName char(80)
 ,@Parm_UserName char(80)
 ,@Parm_WorkStation char(80)
AS
 RETURN
GO

IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_First_SessionInfo_Key00')
  DROP PROCEDURE [dbo].[up_First_SessionInfo_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Last_SessionInfo_Key00')
  DROP PROCEDURE [dbo].[up_Last_SessionInfo_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Prior_SessionInfo_Key00')
  DROP PROCEDURE [dbo].[up_Prior_SessionInfo_Key00]
GO
IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P'   and [name] = 'up_Next_SessionInfo_Key00')
  DROP PROCEDURE [dbo].[up_Next_SessionInfo_Key00]
GO

CREATE PROCEDURE [dbo].[up_First_SessionInfo_Key00]
AS
  SELECT 1 AS RecId
GO

CREATE PROCEDURE [dbo].[up_Last_SessionInfo_Key00]
AS
  SELECT 1 AS RecId
GO

CREATE PROCEDURE [dbo].[up_Next_SessionInfo_Key00] @oldRecId integer
AS
  SELECT 0 AS RecId
GO

CREATE PROCEDURE [dbo].[up_Prior_SessionInfo_Key00] @oldRecId integer
AS
  SELECT 0 AS RecId
GO

