mysql 存储过程
By skyshappiness Posted 2017-11-04 11:00:30 In


存储过程创建指令:

delimiter $                                                                        --定义已 $ 符结尾

create PROCEDURE sp_test1()                                            --创建过程名称
BEGIN
create table test1(id int, name varchar(100));                       --多条执行语句
insert into test1 values(1, 'leili');
select * from test1;
END 
$
delimiter ;

call sp_test1();                                                                    --调用执行过程

DROP PROCEDURE sp_test1;                                                --删除存储过程

delimiter $
create PROCEDURE update_reply_count(IN article_id int, IN open_id varchar(255), IN reply_content varchar(255))
BEGIN
insert into blog_article_reply (`article_id`, `open_id`, `reply_content`) values (article_id, open_id, reply_content);
update blog_article set `reply_count` = reply_count + 1 where id = article_id;
END
$
delimiter ;

call update_reply_count(1, 'test_open_id', 'test_reply_content');
友情链接
联系方式
  • 邮箱 / E-mail:skyshappiness@gmail.com