I am looking for a flexible update stored procedure. I made this one. When i call this CALL spUpdatePage(1,'a','b','c''d') it works fine.
Do i have to pass always in this example 5 params?
Can i also do this
CALL spUpdatePage(1,'a','c')
and that the stored procedure knows that i only want to update the columns name and description?
CREATE DEFINER=`root`@`localhost` PROCEDURE `spUpdatePage`(
IN `pKey` INT(4),
IN `name` VARCHAR(255),
IN `title` VARCHAR(255),
IN `description` VARCHAR(255),
IN `keywords` VARCHAR(255))
UPDATE
pages
SET
name = COALESCE(name, name),
title = COALESCE(title, title),
description = COALESCE(description, description),
keywords = COALESCE(keywords, keywords)
WHERE
id = pKey