打开workbench,点击下面的按钮
编写存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `new_procedure10`(IN myId int,IN myTitle varchar(20),IN myContent varchar(20))
BEGIN
if myTitle is NULL then
select title into myTitle from blog where id=myId;
end if;
if myContent is NULL then
select content into myContent from blog where id=myId;
end if;
update blog set title = myTitle,content=myContent
where id=myId;
END
if…then …end if条件语句
IN 接受参数
Select…into赋值变量
调用存储过程
Call new_ procedure10(1,NULL,NULL) 和call new_procedure10(1,’测试标题’ ,’测试正文’)