0

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

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Aussie_Here
0

What error do you get when you execute your code? (That would help in figuring out the problem.)

-Brian

0

Thanx Brian for ur reply. It's too late but I got it worked :)

Edited by Aussie_Here: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.