如果if成立,执行赋值给@pMsg ,然后插入一笔记录给表tbSMNotice,如果出错则跳到ERROR_QUIT,回退!否则往下COMMIT TRAn,return返回,结束!不过你似乎漏了一个begin tran,应该放在insert之前

解决方案 »

  1.   

    if @message = '2'--如果发送信息是2,则执行下面begin
    select @pMsg =  '彩铃资费包括:月租费5元(每月收取);歌曲使用费根据不同的歌曲有不同定价(一次性收取),一般是2-5元'--给@pMsg赋值
    insert into tbSMNotice(fdcSourAddr,fdcDestAddr,fdcFeeAddr,fdcMessage,fdiFeeType,fdiFmtType,fdiArea,fdcSubArea,fdiUserType)
    values(@Haoma + '12530',@SourAddr,@SourAddr,@pMsg, 70000 ,0,@iArea,@cSubArea,@iUserType)--做新增数据功能
    if @@error <> 0 goto ERROR_QUIT--如果出错,则退出 COMMIT TRAN--提交
    return
    end-------------
    整个的结构就是
    if @message = '2'--如果发送信息是2,则执行下面begin
    select @pMsg =  ''--给@pMsg赋值
    insert into tbSMNotice(fdcSourAddr) values(@Haoma)--做新增数据功能
    if @@error <> 0 goto ERROR_QUIT--如果出错,则退出
    COMMIT TRAN--提交
    return
    end
    ---------------
    if @message = '2'--如果发送信息是2,则执行下面   begin
    ---
       end
    else
       begin
    ---
       end