• 存储过程事物


     create  proc sp_submit_topic
     2 
     3 @topicId int,
     4 @content varchar(1000),
     5 @uid varchar(20),
     6 @datetime datetime
     7 
     8 as
     9 
    10 begin tran --开发事物
    11 
    12 insert into tb_re_topic
    13 values
    14 (
    15   @topicId,@uid,@content,@datetime
    16 )
    17 
    18 if @@error<>0 --表示出现了错误
    19 begin
    20   rollback tran  --回滚 
    21 end
    22 
    23 --没有出现错误,继续向下执行
    24 
    25 declare @value int
    26 
    27 select @value=to_num from tb_topic where _id=@topicId
    28 
    29 update tb_topic set to_num=@value+1 where _id=@topicId
    30 
    31 if @@error<>0  --再次判断是否出现了错误
    32 begin
    33   rollback tran
    34 end
    35 
    36 commit tran--  提交事物

    作者:水木    
     
  • 相关阅读:
    网页加载进度条
    BFC
    Java — 基础语法
    Python — 多进程
    Python — 进程和线程
    Python — 面向对象进阶2
    Python — 面向对象编程基础
    Linnux 05
    Linnux 04
    Linnux 03
  • 原文地址:https://www.cnblogs.com/hsapphire/p/1549625.html
Copyright © 2020-2023  润新知