DROP PROCEDURE IF EXISTS proc_sample1;
CREATE PROCEDURE proc_sample1(IN pFruitId VARCHAR(255))
BEGIN
 SET @strSQL = 'SELECT fruit_name 
                  FROM fruits
                 WHERE fruit_id = ?';
                 
  SET @pFruitId = pFruitId;               
  
  PREPARE stmt FROM @strSQL;
  EXECUTE stmt USING @pFruitId;
  DEALLOCATE PREPARE stmt;                      
END

Leave a reply