CREATE PROCEDURE `spSignalRSendMessage` ( `P_FromRoleTypeId` INTEGER , `P_FromUserId` INTEGER , `P_FromSourceId` INTEGER , `P_ToRoleTypeId` INTEGER , `P_ToUserId` INTEGER , `P_ToSourceId` INTEGER , `P_message` LONGTEXT , `P_FileName` NVARCHAR (?) , `P_ChatGroupId` INTEGER , `P_CreatedUserId` INTEGER , `P_ContentPath` VARCHARACTER (?) , `P_ConnectionId` NVARCHAR (?) ) BEGIN DECLARE `l_ChatId` INTEGER DEFAULT ? ; IF ( `P_ChatGroupId` = ? ) THEN INSERT INTO `tchat` ( `FromRoleTypeId` , `FromUserId` , `FromSourceId` , `ToRoleTypeId` , `ToUserId` , `ToSourceId` , `ChatDetail` , `Contentpath` , `ChatGroupId` , `CreatedUserId` , `CreatedDateTime` ) VALUES ( `P_FromRoleTypeId` , `P_FromUserId` , `P_FromSourceId` , `P_ToRoleTypeId` , `P_ToUserId` , `P_ToSourceId` , `P_message` , `P_ContentPath` , `P_ChatGroupId` , `P_CreatedUserId` , NOW ( ) ) ; SET `l_ChatId` = `LAST_INSERT_ID` ( ) ; SELECT `SR` . `ConnectionId` , `l_ChatId` AS `ChatId` , `U` . `Name` AS `UserName` FROM `vida_lms` . `tsignalrconnection` `SR` INNER JOIN `tuser` `U` ON `U` . `Id` = `SR` . `UserId` WHERE `SR` . `UserId` = `P_ToUserId` AND `IsConnected` = ? 