Hi
I've been trying to solve the following problem for a few days but everytime I get the error msg even when the entered value doesn't conflict with the statement. Plz I need an urgent help
I have the following tables:
booking
bookingId (PK)
subjectId (FK)
Subject
subjectId (PK)
termId
I want to create a trigger to check the inserted values in booking table . If there's another subject have the same termId as the inserted one I should get an error msg. I tried to do the following but it didn't work
Create Trigger tr_check ON
booking
FOR INSERT, UPDATE
AS
BEGIN
IF EXISTS( Select b.bookingId From
booking b, inserted i, subject s1, subject s2, subject s
WHERe
b.subjectId=s1.subjectId AND
i.subjectId=s2.subjectId AND
s1.subjectId=s.subjectId AND
s2.offeringId=s.subjectId AND
s1.termId=s2.termId )
Raiserror('ERROR',10,4)
ROLLBACK TRANSACTION
END
Thanx