• 触发器小练


    ALTER Trigger [dbo].[triVehicle] On [dbo].[OP_VehicleInfo]
    for insert
    As
    DECLARE @order int;
    DECLARE @outorder int;
    set @order = (select max(InSideSort)+1 from OP_VechileState) ;
    set @outorder = (select max(OutsideSort)+1 from OP_VechileState) ;
    INSERT into OP_VechileState select inserted.vehicleid,@order ,@outorder,'1',null from inserted

    、、、、、

    ALTER Trigger [dbo].[trdVehicle] On [dbo].[OP_VehicleInfo]
    for Delete
    As
    Delete dbo.OP_VechileState From dbo.OP_VechileState br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_Clean From dbo.OP_Clean br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_DutyInfo From dbo.OP_DutyInfo br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_Vacation From dbo.OP_Vacation br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_Maintain From dbo.OP_Maintain br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_VehicleBusinessInner From dbo.OP_VehicleBusinessInner br , deleted d Where br.VehicleID=d.VehicleID
    Delete dbo.OP_VehicleBusinessOuter From dbo.OP_VehicleBusinessOuter br , deleted d Where br.VehicleID=d.VehicleID

    、、、、、

    ALTER Trigger [dbo].[triVehiclestate] On [dbo].[OP_VechileState]
    for update
    As
    if update([state])
    begin
    update OP_VechileState set preState =d.state from OP_VechileState vs , deleted d where vs.VehicleId = d.VehicleId
    end

  • 相关阅读:
    CF1324F Maximum White Subtree——换根dp
    bzoj3029 守卫者的挑战
    k8s-pod
    k8s 介绍
    docker-dockerfile
    docker学习
    git
    windows 上git安装及gitlab 连接
    gitlab 配置管理
    gitlab安装/配置/维护
  • 原文地址:https://www.cnblogs.com/sijiyong/p/3518624.html
Copyright © 2020-2023  润新知