cmd="insert into DutyPlan (Title,Author,AuthorDept,AuthorDutyCode,timestart,DutyMan,DutyManDutyCode,DutyManDept,
DutyLeader,DutyLeaderDutyCode,DutyLeaderDept,DutyTopLeader,DutyTopLeaderDutyCode,DutyTopLeaderDept,StartTime,LinkPage,Cata)"
+"values ('"+title+"','"+author+"','"+authordept+"','"+authordutycode+"','"+timestart+"','"+dutyman+"','"+dutymandutyCode+"','"+dutymandept+"','"+dutyleader+"','"+dutyleaderdutyCode+"','"+dutyleaderdept+"','"+dutytopleader+"','"+dutytopleaderdutycode+"','"+dutytopleaderdept+"','"+starttime+"','"+LinkPage+"','通知')";
我在*.aspx.cs文件里写了一条插入语句
现在对DutyPlan 表写了一个触发器
我的目的是当这条插入语句执行的时候
分别给DutyMan,DutyLeader,DutyTopLeader三个人触发一条insert语句
我分别写了三个触发器:
第一个:
CREATE TRIGGER [dutyplan1] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyMan,DutyManDept,DutyManDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity
第二个:
CREATE TRIGGER [dutyplan2] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyLeader,DutyLeaderDept,DutyLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity
第三个:
CREATE TRIGGER [dutyplan3] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyTopLeader,DutyTopLeaderDept,DutyTopLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity但是结果只是对第一条有用
谁能指点我一下,真是万分感激!
DutyLeader,DutyLeaderDutyCode,DutyLeaderDept,DutyTopLeader,DutyTopLeaderDutyCode,DutyTopLeaderDept,StartTime,LinkPage,Cata)"
+"values ('"+title+"','"+author+"','"+authordept+"','"+authordutycode+"','"+timestart+"','"+dutyman+"','"+dutymandutyCode+"','"+dutymandept+"','"+dutyleader+"','"+dutyleaderdutyCode+"','"+dutyleaderdept+"','"+dutytopleader+"','"+dutytopleaderdutycode+"','"+dutytopleaderdept+"','"+starttime+"','"+LinkPage+"','通知')";
我在*.aspx.cs文件里写了一条插入语句
现在对DutyPlan 表写了一个触发器
我的目的是当这条插入语句执行的时候
分别给DutyMan,DutyLeader,DutyTopLeader三个人触发一条insert语句
我分别写了三个触发器:
第一个:
CREATE TRIGGER [dutyplan1] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyMan,DutyManDept,DutyManDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity
第二个:
CREATE TRIGGER [dutyplan2] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyLeader,DutyLeaderDept,DutyLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity
第三个:
CREATE TRIGGER [dutyplan3] ON dbo.DutyPlan
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyTopLeader,DutyTopLeaderDept,DutyTopLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity但是结果只是对第一条有用
谁能指点我一下,真是万分感激!
第一条的:DutyMan,DutyManDept,DutyManDutyCode
第二条的:DutyLeader,DutyLeaderDept,DutyLeaderDutyCode
第三条的:DutyTopLeader,DutyTopLeaderDept,DutyTopLeaderDutyCode
怎么写在一起阿??
每天要排值班计划表,包括值班员,值班处长,值班部首长
每排一条计划,就给这三个人各自触发一条通知
怎么写阿?
如果要写触发器的话,你就是三条简单的insert么
完全可以写在一个触发器里面:
insert ....;
insert ...;
insert ...;
http://www.yesky.com/20030402/1660720.shtml
FOR INSERT
AS
insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyMan,DutyManDept,DutyManDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity;insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyLeader,DutyLeaderDept,DutyLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity;insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyTopLeader,DutyTopLeaderDept,DutyTopLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@@identity;好像还是不对的
----------
CREATE TRIGGER [dutyplan1] ON dbo.DutyPlan
FOR INSERT
AS Declare @intTmp int
Set @intTmp = @@identity insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyMan,DutyManDept,DutyManDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@intTmp;insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyLeader,DutyLeaderDept,DutyLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@intTmp;insert into PendingDoc (Title,StartTime,Author,AuthorDutyCode,Dept,CurrentOper,CurrentOperDept,CurrentOperDutyCode,LinkPage,LinkMatchID,Cata)
select title,timestart,Author,AuthorDutyCode,Authordept,DutyTopLeader,DutyTopLeaderDept,DutyTopLeaderDutyCode,LinkPage,DutyPlanID,Cata from DutyPlan where DutyPlanID =@intTmp;