If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Problems with Delete statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-03, 02:15
VB_Oracle VB_Oracle is offline
Registered User
 
Join Date: Nov 2003
Posts: 22
Problems with Delete statement

Hi,

I have the table: R1(A, B, C)

Primary Key (A, B)
Foreign Key (A)

I'm trying to delete a row using the query: delete from R1 where A = 123;

However, Oracle freezes on me. Please help. Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-03-03, 02:42
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
A foreign key must reference the entire primary key or unique set of columns, thus foreign key (A) in your below table must indicate that (A) refers to a column in another table that i'll call R.

R(A) primary key (A)
R1 (A, B, C) primary key (A, B)
foreign key (A) references R(A)

By default deleting the value of A will have no effect, as A in this case is a child. An error would arise if the primary key of R1 was reference as a foreign key elsewhere as A is part of the parent key.

However given the above simple relations,

delete from R1 where a = x produces no error.

Thus, the problem is not constraint related with default constraint options.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456; 12-03-03 at 02:56.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On