zoukankan      html  css  js  c++  java
  • 触发器(当2个表中的相应值改变时同时改变一个表中的一个字段)(同时有处理“无法解决 equal to 操作的排序规则冲突”问题)

    create trigger GetAllPointOnUserInfoChange
    on UserInfo
    for update,insert
    as 


    declare @point int,@point_bank int,@point_mno int,@point_present int,@point_BabaoVoteYY int,@userid nvarchar

    select @point=inserted.point,@point_bank=inserted.point_bank,@point_mno=inserted.point_mno,@point_present=inserted.point_present,@userid=inserted.userid,@point_BabaoVoteYY=BabaoVoteYY.point from inserted left join BabaoVoteYY on inserted.userid collate Chinese_PRC_CI_AS=BabaoVoteYY.userid collate Chinese_PRC_CI_AS

    if @point_BabaoVoteYY is null
      
    set @point_BabaoVoteYY=0  

    update UserInfo set allpoint=@point+@point_bank+@point_mno+@point_present+@point_BabaoVoteYY where userid=@userid

    **********************************************************************************************
    create trigger GetAllPointOnBabaoVoteYYChange
    on BabaoVoteYY
    for update,insert
    as 

    declare @point_UserInfo int,@point_bank_UserInfo int,@point_mno_UserInfo int,@point_present_UserInfo int,@point int,@userid nvarchar

    select @point_UserInfo=UserInfo.point,@point_bank_UserInfo=UserInfo.point_bank, @point_mno_UserInfo=UserInfo.point_mno,@point_present_UserInfo=UserInfo.point_present,@userid=inserted.userid,@point=inserted.point from inserted,UserInfo where inserted.userid collate Chinese_PRC_CI_AS=UserInfo.userid collate Chinese_PRC_CI_AS

    update UserInfo set allpoint=@point_UserInfo+@point_bank_UserInfo+@point_mno_UserInfo+@point_present_UserInfo+@point where userid=@userid

  • 相关阅读:
    小数化分数2
    Sum of divisors
    Subsequence
    Lowest Bit
    Specialized Four-Digit Numbers
    Hunters
    Pet
    测试你是否和LTC水平一样高
    Bank Interest
    bzoj 1295
  • 原文地址:https://www.cnblogs.com/xiaodi/p/128150.html
Copyright © 2011-2022 走看看