CREATE PROCEDURE `spAddDocumentPath` ( IN `P_TeacherId` INTEGER , IN `P_ContentPath` VARCHARACTER (?) , IN `P_ContentTitle` VARCHARACTER (?) , IN `P_ContentLink` VARCHARACTER (?) , IN `P_IsCommon` BIT , IN `P_Duration` VARCHARACTER (?) , IN `P_ContentTypeId` INTEGER ) BEGIN IF EXISTS ( SELECT ? FROM `tteacher` WHERE `id` = `P_TeacherId` ) THEN IF `P_ContentTypeId` IN (...) THEN START TRANSACTION ; INSERT INTO `tteachercontent` ( `TeacherId` , `ContentTitle` , `ContentPath` , `ContentTypeId` , `CreatedDateTime` , `IsCommon` ) VALUES ( `P_TeacherId` , `P_ContentTitle` , `P_ContentPath` , `P_ContentTypeId` , NOW ( ) , `P_IsCommon` ) ; SELECT `LAST_INSERT_ID` ( ) ; COMMIT ; ELSE START TRANSACTION ; INSERT INTO `tteachercontent` ( `TeacherId` , `ContentLink` , `ContentPath` , `ContentTitle` , `ContentTypeId` , `CreatedDateTime` , `IsCommon` , `Duration` ) VALUES ( `P_TeacherId` , `P_ContentLink` , `P_ContentPath` , `P_ContentTitle` , `P_ContentTypeId` , NOW ( ) , `P_IsCommon` , `P_Duration` ) ; SELECT `LAST_INSERT_ID` ( ) ; COMMIT ; END IF ; ELSE SELECT ? ; END IF ; END 