sqlserver 触发器 (建在表下面的)案列

USE [easdata]
GO
/****** Object:  Trigger [dbo].[t_con_projectstart_upd]    Script Date: 2019/2/19 22:39:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
  ALTER  TRIGGER   [dbo].[t_con_projectstart_upd]   ON    [dbo].[T_CON_ProjectStart]
FOR  UPDATE
as
BEGIN
    IF  UPDATE (FBillStatus)
    begin
        DECLARE  @FID    NVARCHAR( 255),@status   nvarchar( 10),@oldstatus   nvarchar( 10), @Fnumber  NVARCHAR( 255),
		 @fprojectcode NVARCHAR( 255),@fpersonid NVARCHAR( 255),@FCreatorID NVARCHAR( 255)
        select  @FID =FID, @status =fbillstatus ,@fprojectcode=fprojectcode,@FCreatorID =FCreatorID   FROM  inserted 
		select @fpersonid =fpersonid from T_PM_User where fid = @FCreatorID
      if (@status ='1')  
        if not exists(select fnumber from T_BD_Project where fnumber = @fprojectcode)
	insert into T_BD_Project(
		fid,
		fname_l2,fnumber,fisleaf,flevel,flongnumber,ftype,fstatus,FScheduleStartDate,FSchedulEndDate,
        FCreatorID,FCreateTime,
        FLastUpdateUserID,FLastUpdateTime,
        FControlUnitID,FDisplayName_L2,FIsListItem,
        FCompanyID,FIsSysCreate,fisprostart,FPrjManagerID
        )
    select 
       [dbo].[newbosid]('DADE05EE') newfid,
	   fprojectname,fprojectcode,1 fisleaf,1 flevel,fprojectcode,0 ftype,1 fstatus,fstartdate,fenddate,
       FCreatorID,FCreateTime,
	   FLastUpdateUserID,FLastUpdateTime,
	   FControlUnitID,fprojectname,1 FIsListItem,
	   FControlUnitID,0 FIsSysCreate,1 fisprostart, @fpersonid
  FROM t_con_projectstart where fid =@fid;
  END;
END

在二开单据点击审核的时候 ,向系统中的一个表中插入数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值