CREATE PROCEDURE `spAddBankDetails` ( IN `P_AccountId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_AccountHolderName` VARCHARACTER (?) , IN `P_AccountNumber` INT8 (?) , IN `P_IFSCCode` VARCHARACTER (?) , IN `P_EmailId` VARCHARACTER (?) ) BEGIN IF `P_AccountId` = ? THEN IF EXISTS ( SELECT ? FROM `tbankaccountdetail` WHERE `TeacherId` = `P_TeacherId` ) THEN SELECT ? ; ELSE START TRANSACTION ; INSERT INTO `tbankaccountdetail` ( `TeacherId` , `AccountHolderName` , `AccountNumber` , `IFSCCode` , `EmailId` ) VALUES ( `P_TeacherId` , `P_AccountHolderName` , `P_AccountNumber` , `P_IFSCCode` , `P_EmailId` ) ; SELECT ? ; COMMIT ; END IF ; ELSEIF `P_AccountId` > ? THEN IF EXISTS ( SELECT ? FROM `tbankaccountdetail` WHERE `TeacherId` = `P_TeacherId` ) THEN UPDATE `tbankaccountdetail` SET `AccountHolderName` = `P_AccountHolderName` , `AccountNumber` = `P_AccountNumber` , `IFSCCode` = `P_IFSCCode` , `EmailId` = `P_EmailId` WHERE `Id` = `P_AccountId` ; SELECT ? ; ELSE SELECT ? ; END IF ; END IF ; END 