|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
--小弟写的一个触发器,作用是在科目挂了辅助核算并且有余额的情况下不允许修改辅助核算,请高手指点写的对不对:
--------------------------------------------------------
if exists(select 1 from master..sysobjects where name='fujian') drop trigger fujian
CREATE TRIGGER fujian
ON code
AFTER UPDATE
AS
declare @code varchar(20),@person varchar(20),@cus varchar(20),@sup varchar(20),@dept varchar(20),@item varchar(20)
select @code = ccode from deleted
select @person = bperson from deleted
select @cus = bcus from deleted
select @sup = bsup from deleted
select @dept = bdept from deleted
select @item = bitem from deleted
IF (( UPDATE (bperson) or UPDATE (bcus) or UPDATE (bsup) or UPDATE (bdept) or UPDATE (bitem)))
and @code in (select ccode from gl_accsum)
BEGIN
UPDATE code
SET bperson = @person,
bcus=@cus,
bsup=@sup,
bdept=@dept,
bitem=@item
WHERE ccode=@code
print'you can t do this action'
END;
GO
-- Test the trigger.
UPDATE code
SET bperson = 0,bsup=0
WHERE ccode ='1131';
GO |
|