bertrandkis
Programmer
I have created the following trigger
CREATE TRIGGER Learner_ITrig ON dbo.Learner
FOR insert
AS
Begin
if (select count(LearnerID) from learner where Learnerid=(select LearnerID from Inserted))>1
begin
RAISERROR ('This ID already exists in the database', 16, 1)
rollback tran
end
If ( (select Surname from Inserted) is null and (select Firstnames from Inserted) is null )
BEGIN
rollback tran
END
end
The problem is that sometimes when I insert a new record it works fine but sometimes
I get this error:
Server: Msg 3903, Level 16, State 1, Procedure Learner_UTrig, Line 17
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
The statement has been terminated.
When this trigger fires,
Can someone tell me what is wrong with this trigger?
CREATE TRIGGER Learner_ITrig ON dbo.Learner
FOR insert
AS
Begin
if (select count(LearnerID) from learner where Learnerid=(select LearnerID from Inserted))>1
begin
RAISERROR ('This ID already exists in the database', 16, 1)
rollback tran
end
If ( (select Surname from Inserted) is null and (select Firstnames from Inserted) is null )
BEGIN
rollback tran
END
end
The problem is that sometimes when I insert a new record it works fine but sometimes
I get this error:
Server: Msg 3903, Level 16, State 1, Procedure Learner_UTrig, Line 17
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
The statement has been terminated.
When this trigger fires,
Can someone tell me what is wrong with this trigger?