首页 > 数据库技术 > 详细

MySQL存储过程语法

时间:2015-11-25 00:24:50      阅读:358      评论:0      收藏:0      [点我收藏+]
create procedure t_insert_table()  
begin  
    /** 标记是否出错 */  
    declare t_error int default 0;  
    /** 如果出现sql异常,则将t_error设置为1后继续执行后面的操作 */  
    declare continue handler for sqlexception set t_error=1-- 出错处理  
    /** 显式的开启事务,它开启后,事务会暂时停止自动提交*/  
    -- start transaction;  
    /** 关闭事务的自动提交 */  
    set autocommit = 0;  
    insert into t_bom_test(parent_id,child_id) values(D,abc);  
    insert into t_trigger_test(name,age) values(zhangsan,null);  
    /** 标记被改变,表示事务应该回滚 */  
    if t_error=1 then  
        rollback-- 事务回滚  
    else  
        commit-- 事务提交  
    end if;  
    -- rollback;  
    -- commit;  
end 
 

 

MySQL存储过程语法

原文:http://www.cnblogs.com/walk-the-Line/p/4993372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!