Again Constraint Problem

Again Constraint Problem

Post by Bauj » Tue, 24 Jul 2001 21:41:19



I have two tables, One is Contact and another is attendance table. For both
table, structures are as follow:

Contact
---------
Contactid smallint (Primary Key)
name varchar(20)

Attendance
-----------
AttendeeID Smallint
AttendeeType char(1)
AttendeeYear char(4)

I set the following constraint:
 ALTER TABLE Attendance ADD
 CONSTRAINT FK_ContactAttendance FOREIGN KEY
  (AttendeeID) REFERENCES dbo.Contacts(ContactId)
  On UPDATE CASCADE
  On DELETE NO ACTION,
  Constraint CK_Attendees Check (AttendeeType='O') or (AttendeeType='C')

Then I tried to test the above constraint for delete any contact for which
attendance is exist, it gives me following error:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E2F)
DELETE statement conflicted with COLUMN REFERENCE constraint
'FK_ContactAttendance'.
The conflict occurred in database 'Employee', table 'Attendance', column
'AttendeeID'.

I dont understand the problem, what wrong I am doing?

If someone help me in this matter, I will be thankful.

 
 
 

Again Constraint Problem

Post by Ole Kristian Bang? » Tue, 24 Jul 2001 22:07:08




Quote:> I dont understand the problem, what wrong I am doing?

> If someone help me in this matter, I will be thankful.

What about looking up in the manual what "ON DELETE NO ACTION" means? As
far as I can see et means that the server should not do anything, except
raise an exception...

--
Ole Kristian

"What we call religion is too often a means of trickery in that we project
the self into "God," so it can, by association, live life everlastingly."

 - Terrence Webster-Doyle.

 
 
 

1. open ADO cnt again and again

I have a Word file that I'm connecting to an mdb via DSN-less ADO
connection. Everything works great. However, I'm going to probably need to
work it where the user will open andn close the connection several times
within a short time period. This is *not* a mail merge situation. Anyway, in
the past, I've run into errors when the code attempts to reopen, or close
and create a new connection to the same database over and over again. How
can I get around this?

Richard Choate

2. how to modify a job's schedule in Delphi or VB

3. Connection Again and Again

4. help with 4gl reports

5. multithreading again and again!

6. Transaction protocol full

7. Licensing Again Again

8. xp_sendmail in SQL 6.0

9. multithreading, again and again!

10. Synonyms - again (Graeme hits again!)

11. Constraints and TTable.Constraints

12. Primary key constraints vs Unique constraints