CREATE PROCEDURE `spGetContentTitle` ( IN `P_ContentId` INTEGER , IN `P_ContentPath` VARCHARACTER (?) ) BEGIN IF EXISTS ( SELECT ? FROM `tteachercontent` WHERE `id` = `P_ContentId` AND `Contentlink` IS NULL ) THEN SELECT `CONCAT` ( `ContentPath` , ? , `ContentTitle` ) AS `ContentPath` FROM `tteachercontent` WHERE `id` = `P_ContentId` ; ELSE START TRANSACTION ; INSERT INTO `tteachercontent` ( `ContentPath` , `ContentTitle` , `ContentLink` , `TeacherId` , `CreatedDateTime` ) SELECT `P_ContentPath` , `ContentTitle` , `ContentLink` , `TeacherId` , `CreatedDateTime` FROM `tteachercontent` WHERE `id` = `P_ContentId` ; SELECT `ContentPath` AS `ContentPath` , `id` AS `ContentId` FROM `tteachercontent` WHERE `id` = `LAST_INSERT_ID` ( ) ; COMMIT ; END IF ; END 