在要进行的表下进行建立触发器replyTRIGGER,当此表下的条件满足我要设的条件就触发.
SET
QUOTED_IDENTIFIER
ON
GO
SET ANSI_NULLS ON
GO
ALTER TRIGGER replyTRIGGER ON dbo.recmsg
FOR INSERT
AS
declare @@usernum varchar ( 20 )
declare @@usertext varchar ( 1000 )
select @@usernum = usercallno, @@usertext = msg from inserted
if @@usernum = ' 106573096245 '
begin
insert sendmsg (usercallno,msg,sndflg,res) values ( ' 106573096245 ' , ' ZF: ' + @@usertext , 0 , ' 1 ' )
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
GO
SET ANSI_NULLS ON
GO
ALTER TRIGGER replyTRIGGER ON dbo.recmsg
FOR INSERT
AS
declare @@usernum varchar ( 20 )
declare @@usertext varchar ( 1000 )
select @@usernum = usercallno, @@usertext = msg from inserted
if @@usernum = ' 106573096245 '
begin
insert sendmsg (usercallno,msg,sndflg,res) values ( ' 106573096245 ' , ' ZF: ' + @@usertext , 0 , ' 1 ' )
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
如这个触发器:
CREATE
TRIGGER
LUZL.dd
NO CASCADE BEFORE
UPDATE OF
MODIFY_DATE
ON LUZL.ITEM
REFERENCING
OLD AS o
NEW AS n
FOR EACH ROW
MODE DB2SQL
set n.modify_date = current timestamp
NO CASCADE BEFORE
UPDATE OF
MODIFY_DATE
ON LUZL.ITEM
REFERENCING
OLD AS o
NEW AS n
FOR EACH ROW
MODE DB2SQL
set n.modify_date = current timestamp
就是在执行update之前将modify_date的值改成current timestamp.【深海原创】
以上归为项目中实例运用!如果大家有好的,一起讨论哦!可以联系LiFuyun.net