• 增、删、改开放时间表时,同步数据至 CP


    -- =============================================
    -- Author: dao
    -- Create date: 2017-11-15
    -- Description: 增、删、改开放时间表时,同步数据至 CP
    -- =============================================
    CREATE TRIGGER [dbo].[TR_LM_SYS_KaiFangShiJian_IDU]
    ON [dbo].[LM_SYS_KaiFangShiJian]
    FOR INSERT,DELETE,UPDATE
    AS
    BEGIN
    --新增
    if(exists(select 1 from inserted) and not exists(select 1 from deleted))
    begin
    INSERT INTO LM_KQ_KaoQingAnPai
    ( KaoQingAnPaiID ,
    ShiYanShiID ,
    KaiShiRiQi ,
    JieShuRiQi ,

    XingQingBianHao ,
    KaiShiShiJian ,
    JieShuShiJian ,
    SystemType ,

    CreateOn ,
    CreateDate ,
    UpdateOn ,
    UpdateDate
    )
    SELECT CONVERT(VARCHAR(100), A.KaiFangShiJianID) AS KaiFangShiJianID ,
    CONVERT(VARCHAR(100), A.ShiYanShiID) AS ShiYanShiID ,
    A.KaiShiRiQi ,
    A.JieShuRiQi ,

    A.XingQingBianHao ,
    A.KaiShiShiJian ,
    A.JieShuShiJian ,
    AS SystemType ,

    NULL ,
    GETDATE() ,
    NULL ,
    GETDATE()
    FROM Inserted AS A
    INNER JOIN LM_SYS_ShiYanShiXinXi AS B ON A.ShiYanShiID = B.ShiYanShiID
    INNER JOIN LM_MJ_Men AS C ON B.MenID = C.MenID
    WHERE A.ShiFouMoRen = 0
    AND B.IsDelete = 0
    AND C.IsDelete = 0;
    end

    --删除
    if(not exists(select 1 from inserted) and exists(select 1 from deleted))
    begin
    delete from LM_KQ_KaoQingAnPai
    where KaoQingAnPaiID in(select KaiFangShiJianID from deleted)
    end

    --更新
    if(exists(select 1 from inserted) and exists(select 1 from deleted))
    begin
    update LM_KQ_KaoQingAnPai set ShiYanShiID=a.KaiFangShiJianID
    ,KaiShiRiQi=a.KaiShiRiQi,JieShuRiQi=a.JieShuRiQi
    ,XingQingBianHao=a.XingQingBianHao,KaiShiShiJian=a.KaiShiShiJian
    ,JieShuShiJian=a.JieShuShiJian,UpdateDate=GETDATE()
    from inserted a
    where KaoQingAnPaiID=a.KaiFangShiJianID
    end

    END

    GO

  • 相关阅读:
    jQuery制作焦点图(轮播图)
    mysql 存储引擎的选择
    linux 系统操作
    把网页转换成doc 格式的文件,方便用户下载PHP 方法
    多年级勾选
    zend studio 破解
    win7下安装Linux实现双系统全攻略
    【Linux】Linux中常用操作命令
    PHP xmapp 下面安装 Composer-Setup.exe
    ecshop中smarty比较操作符(eq,ne,neq)含义
  • 原文地址:https://www.cnblogs.com/chidao/p/12938056.html
Copyright © 2020-2023  润新知