Hello All,
I need to search by student name and my stored procedure is shown below
DROP PROCEDURE IF EXISTS `LoadStudentsByName` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `LoadStudentsByName`
(
v_StartRowIndex int,
v_PageSize int,
v_SearchTerm varchar(500)
)
BEGIN
SET @tempSearchTerm=v_SearchTerm;
SET @START = v_StartRowIndex;
SET @LIMIT = v_PageSize;
IF @tempSearchTerm != '' THEN
PREPARE STMT FROM "SELECT ID, Name, Branch, Address FROM Student WHERE Name LIKE '%" + v_SearchTerm + "%' Order by Name LIMIT ?,?";
ELSE
PREPARE STMT FROM "SELECT ID, Name, Branch, Address FROM Student Order by Name LIMIT ?,?";
END IF;
EXECUTE STMT USING @START, @LIMIT;
END $$
DELIMITER ;
but the above stored procedure is not creating because i am adding variable in prepare statement...Can someone suggest how to add variable in prepare statement...
babu