CREATE PROCEDURE `spChatDetailsGet` ( IN `P_ToRoleTypeId` INTEGER , IN `P_ToUserId` INTEGER , IN `P_ToSourceId` INTEGER , IN `P_FromRoleTypeId` INTEGER , IN `P_FromUserId` INTEGER , IN `P_FromSourceId` INTEGER , IN `P_ChatGroupId` INTEGER ) BEGIN IF ( `P_ChatGroupId` = ? ) THEN SELECT `ifnull` ( `C` . `Id` , ? ) AS `ChatId` , `ifnull` ( `C` . `ToRoleTypeId` , ? ) AS `ToRoleTypeId` , `ifnull` ( `C` . `ToUserId` , ? ) AS `ToUserId` , `ifnull` ( `C` . `ToSourceId` , ? ) AS `ToSourceId` , `ifnull` ( `C` . `FromRoleTypeId` , ? ) AS `FromRoleTypeId` , `ifnull` ( `C` . `FromUserId` , ? ) AS `FromUserId` , `ifnull` ( `C` . `FromSourceId` , ? ) AS `FromSourceId` , `ifnull` ( `C` . `ChatDetail` , ? ) AS `ChatDetail` , `ifnull` ( `C` . `ContentPath` , ? ) AS `ContentPath` , `ifnull` ( `C` . `ChatGroupId` , ? ) AS `ChatGroupId` , `ifnull` ( `C` . `CreatedUserId` , ? ) AS `CreatedUserId` , `ifnull` ( `C` . `CreatedDateTime` , ? ) AS `CreatedDateTime` , `ifnull` ( `CG` . `BatchId` , ? ) AS `BatchId` , `ifnull` ( `B` . `Title` , ? ) AS 