CREATE PROCEDURE `spConnectSignalR` ( IN `P_UserName` VARCHARACTER (?) , IN `P_ConnectionId` VARCHARACTER (?) ) BEGIN DECLARE `UserId` INTEGER DEFAULT ? ; SELECT `Id` INTO `UserId` FROM `tuser` WHERE `UserName` = `P_UserName` ; IF ( `UserId` > ? ) THEN BEGIN UPDATE `tsignalrconnection` SET `ConnectionId` = `P_ConnectionId` , `IsConnected` = ? WHERE `UserId` = `UserId` ; SELECT `UserId` AS `Result` ; END ; ELSE BEGIN INSERT INTO `tsignalrconnection` ( `UserId` , `ConnectionId` , `IsConnected` , `ConnectionDateTime` ) VALUES ( `UserId` + `P_ConnectionId` , ? , NOW ( ) ) ; SELECT `UserId` AS `Result` ; END ; END IF ; END 