zoukankan      html  css  js  c++  java
  • sql触发器

    if exists(select [name] from sys.objects where [name]='updateChild' and [type]='TR')
    drop trigger updateChild
    go
    create trigger updateChild
    on TB_ProductType
    for update
    as
    if update(Pids) or update(Pid) or update([Level])
    begin
        update TB_ProductType set Pids=replace(pt.Pids,d.Pids,i.Pids),
        [Level]=case when (i.[Level]<>d.[Level]) then (pt.[Level]+i.[Level]-d.[Level]) else (pt.[Level]) end
        from TB_ProductType pt,deleted d,inserted i
        where charindex('|'+cast(d.ID as nvarchar(20)) +'|',pt.Pids)>0
    end
    go
    model.pid = int.Parse(ddlLM.SelectedValue);
    
            string xzPids = "|0|";
            if (model.pid != 0)
            {
                Model.LM xzModel = bll.GetModelBystrWhere("ID=" + model.pid);
                if (xzModel != null)
                {
                    xzPids = xzModel.pids + model.pid + "|";
                    model.Level = xzModel.Level + 1;
                }
            }
            else 
                model.Level = 1;
            model.pids = xzPids;
    
    
    if (id > 0)
            {
    
                Model.LM model_0 = bll.GetModelBystrWhere("ID=" + id);
                if (model_0 != null)
                {
                    if (model_0.pid != model.pid) //上级已修改
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("update TB_LM set Pids=replace(Pids,"
                            + "'" + model_0.pids + "','" + model.pids + "') where charindex('|"
                            + model_0.ID + "|',Pids)>0");
                    }
                }
            }
  • 相关阅读:
    git cmd 命令在已有的仓库重新添加新的文件夹
    google guava Multimap的学习介绍
    JavaScript笔记基础版
    初识hive
    深入学习HBase架构原理
    初识Azkaban
    MapReduce工作流多种实现方式
    Hive 分组问题
    sqoop使用中的小问题
    Sqoop 结合多种系统的具体应用
  • 原文地址:https://www.cnblogs.com/daixingqing/p/2768273.html
Copyright © 2011-2022 走看看