dbo.QBM_PWriteDialogJournal
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
Interpretation
- Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.
Relations
- No extracted relations.
Typed Edges
- references source dbo.QBM_FCVStringToInt source text reference
- references source dbo.QBM_FGISessionErrorForLog source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
Complete Source
1CREATE PROCEDURE QBM_PWriteDialogJournal(2 @MessageString nvarchar(max),3 @ApplicationName nvarchar(64) = N '',4 @LogonUser nvarchar(64) = N '',5 @MessageType nchar(1) = N 'I',6 @HostName nvarchar(64) = N '',7 @SuppressEntriesCount int = 08)9AS10BEGIN11 DECLARE @messagetypeIntern nchar(1)12 DECLARE @ApplicationNameIntern nvarchar(64)13 DECLARE @HostnameIntern nvarchar(64)14 DECLARE @LogonUserIntern nvarchar(64)15 DECLARE @LevelForLogging char(1) = 'T'16 DECLARE @ProcID int17 DECLARE @Agentvgl varchar(64) = 'OneIM_DatabaseAgent'18 SET XACT_ABORT OFF19 BEGIN TRY20 IF(XACT_STATE()) < 021 BEGIN22 GOTO endLabel23 END24 IF @messagetype NOT IN(N 'W',25 N 'E',26 N 'I',27 'D',28 'T')29 BEGIN30 SELECT @messagetypeIntern = N 'T'31 END32 ELSE33 BEGIN34 SELECT @messagetypeIntern = @messagetype35 END36 IF @LevelForLogging = 'T' AND @messagetypeIntern IN('T',37 'D',38 'I',39 'W',40 'E')41 GOTO doit42 IF @LevelForLogging = 'D' AND @messagetypeIntern IN('D',43 'I',44 'W',45 'E')46 GOTO doit47 IF @LevelForLogging = 'I' AND @messagetypeIntern IN('I',48 'W',49 'E')50 GOTO doit51 IF @LevelForLogging = 'W' AND @messagetypeIntern IN('W',52 'E')53 GOTO doit54 IF @messagetypeIntern = 'E'55 GOTO doit56 GOTO endlabel Doit:57 IF EXISTS(58 SELECT TOP 1 159 FROM sys.sysprocesses p60 WHERE61 p.spid = @@SPID AND p.program_name LIKE @Agentvgl + '%')62 BEGIN63 SELECT @ApplicationNameIntern = 'DBQueue Processor'64 END65 ELSE66 BEGIN67 IF rtrim(isnull(@ApplicationName, N '')) = N ''68 BEGIN69 SELECT TOP 1 @ApplicationNameIntern = rtrim(70 LEFT(program_name, 64))71 FROM sys.sysprocesses72 WHERE73 spid = @@spid74 END75 ELSE76 BEGIN77 SELECT78 @ProcID = dbo.QBM_FCVStringToInt(@Applicationname,79 -123)80 IF @ProcID <> -12381 BEGIN82 IF OBJECT_NAME(@ProcID) > ' '83 BEGIN84 SELECT @ApplicationNameIntern = OBJECT_NAME(@ProcID)85 END86 ELSE87 BEGIN88 SELECT @ApplicationNameIntern = @ApplicationName89 END90 END91 ELSE92 BEGIN93 SELECT @ApplicationNameIntern = @ApplicationName94 END95 END96 END97 IF @MessageString = 'SessionError'98 BEGIN99 SELECT100 @MessageString = CONCAT(dbo.QBM_FGISessionErrorForLog(),101 '50000',102 nchar(9),103 '0',104 nchar(9),105 'logged in ',106 @ApplicationNameIntern,107 nchar(13),108 nchar(10))109 END110 IF rtrim(isnull(@HostName, N '')) = N ''111 BEGIN112 SELECT TOP 1 @HostnameIntern = rtrim(113 LEFT(HostName, 64))114 FROM sys.sysprocesses115 WHERE116 spid = @@spid117 END118 ELSE119 BEGIN120 SELECT @HostnameIntern = @HostName121 END122 IF rtrim(isnull(@LogonUser, N '')) = N ''123 BEGIN124 SELECT TOP 1 @LogonUserIntern = rtrim(125 LEFT(nt_username, 64))126 FROM sys.sysprocesses127 WHERE128 spid = @@spid129 IF rtrim(isnull(@LogonUserIntern, N '')) = N ''130 BEGIN131 SELECT TOP 1 @LogonUserIntern = rtrim(132 LEFT(loginame, 64))133 FROM sys.sysprocesses134 WHERE135 spid = @@spid136 END137 END138 ELSE139 BEGIN140 SELECT141 @ProcID = dbo.QBM_FCVStringToInt(@Applicationname,142 -123)143 IF @ProcID <> -123144 BEGIN145 IF OBJECT_NAME(@ProcID) > ' '146 BEGIN147 SELECT @LogonUserIntern = OBJECT_NAME(@ProcID)148 END149 ELSE150 BEGIN151 SELECT @LogonUserIntern = @LogonUser152 END153 END154 ELSE155 BEGIN156 SELECT @LogonUserIntern = @LogonUser157 END158 END159 IF @SuppressEntriesCount > 0160 BEGIN161 IF EXISTS(162 SELECT TOP 1 1163 FROM(164 SELECT TOP(@SuppressEntriesCount) *165 FROM DialogJournal k166 WITH(nolock)167 ORDER BY MessageDate DESC) AS x168 WHERE169 x.MessageType = @messagetypeIntern AND x.MessageString = @MessageString)170 BEGIN171 GOTO Endlabel172 END173 END174 INSERT INTO DialogJournal(UID_DialogJournal,175 MessageType,176 MessageString,177 MessageDate,178 ApplicationName,179 LogonUser,180 HostName)181 SELECT182 newid(),183 @messagetypeIntern,184 @MessageString,185 GetUTCDate(),186 @ApplicationNameIntern,187 @LogonUserIntern,188 @HostnameIntern189 END TRY190 BEGIN CATCH191 EXEC QBM_PSessionErrorAdd DEFAULT192 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()193 RAISERROR(@Rethrow,194 18,195 1)196 WITH NOWAIT197 END CATCH198 endLabel:199 RETURN200END
Open raw exported source
1 create procedure QBM_PWriteDialogJournal ( @MessageString nvarchar(max), @ApplicationName nvarchar(64) = N'', @LogonUser nvarchar(64) = N''2, @MessageType nchar(1) = N'I' , @HostName nvarchar(64) = N'' , @SuppressEntriesCount int = 0 ) as begin declare @messagetypeIntern nchar(1) declare @ApplicationNameIntern3 nvarchar(64) declare @HostnameIntern nvarchar(64) declare @LogonUserIntern nvarchar(64) declare @LevelForLogging char(1) = 'T' declare @ProcID int declare4 @Agentvgl varchar(64) = 'OneIM_DatabaseAgent' SET XACT_ABORT OFF BEGIN TRY If (XACT_STATE()) < 0 BEGIN goto endLabel END if @messagetype not in (N'W'5, N'E', N'I', 'D', 'T') begin select @messagetypeIntern = N'T' end else begin select @messagetypeIntern = @messagetype end if @LevelForLogging = 'T' and6 @messagetypeIntern in ('T', 'D', 'I', 'W', 'E') goto doit if @LevelForLogging = 'D' and @messagetypeIntern in ('D', 'I', 'W', 'E') goto doit if @LevelForLogging7 = 'I' and @messagetypeIntern in ('I', 'W', 'E') goto doit if @LevelForLogging = 'W' and @messagetypeIntern in ('W', 'E') goto doit if @messagetypeIntern8 = 'E' goto doit goto endlabel Doit: if exists (select top 1 1 from sys.sysprocesses p where p.spid = @@SPID and p.program_name like @Agentvgl + '%' )9 begin select @ApplicationNameIntern = 'DBQueue Processor' end else begin if rtrim(isnull(@ApplicationName, N'')) = N'' begin select top 1 @ApplicationNameIntern10 = rtrim(left(program_name, 64)) from sys.sysprocesses where spid = @@spid end else begin select @ProcID = dbo.QBM_FCVStringToInt(@Applicationname, -12311) if @ProcID <> -123 begin if OBJECT_NAME(@ProcID) > ' ' begin select @ApplicationNameIntern = OBJECT_NAME(@ProcID) end else begin select @ApplicationNameIntern12 = @ApplicationName end end else begin select @ApplicationNameIntern = @ApplicationName end end end if @MessageString = 'SessionError' begin select @MessageString13 = concat(dbo.QBM_FGISessionErrorForLog() , '50000', nchar(9), '0', nchar(9) , 'logged in ' , @ApplicationNameIntern , nchar(13), nchar(10) ) end if rtrim14(isnull(@HostName, N'')) = N'' begin select top 1 @HostnameIntern = rtrim(left(HostName, 64)) from sys.sysprocesses where spid = @@spid end else begin 15select @HostnameIntern = @HostName end if rtrim(isnull(@LogonUser, N'')) = N'' begin select top 1 @LogonUserIntern = rtrim(left(nt_username, 64)) from 16sys.sysprocesses where spid = @@spid if rtrim(isnull(@LogonUserIntern, N'')) = N'' begin select top 1 @LogonUserIntern = rtrim(left(loginame, 64)) from17 sys.sysprocesses where spid = @@spid end end else begin select @ProcID = dbo.QBM_FCVStringToInt(@Applicationname, -123) if @ProcID <> -123 begin if OBJECT_NAME18(@ProcID) > ' ' begin select @LogonUserIntern = OBJECT_NAME(@ProcID) end else begin select @LogonUserIntern = @LogonUser end end else begin select @LogonUserIntern19 = @LogonUser end end if @SuppressEntriesCount > 0 begin if exists (select top 1 1 from (select top (@SuppressEntriesCount) * from DialogJournal k with20(nolock) order by MessageDate desc ) as x where x.MessageType = @messagetypeIntern and x.MessageString = @MessageString ) begin goto Endlabel end end insert21 into DialogJournal (UID_DialogJournal, MessageType, MessageString , MessageDate , ApplicationName , LogonUser , HostName) select newid(), @messagetypeIntern22, @MessageString , GetUTCDate() , @ApplicationNameIntern , @LogonUserIntern , @HostnameIntern END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare23 @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH endLabel: return end 24