File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Foreign key access problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Foreign key access problem" Watch "Foreign key access problem" New topic
Author

Foreign key access problem

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi,

I have two tables table1 and table2. I have 3 fields in each tables. I made two of the fields in table1 as composite primary key. Now, I want to make one among these fields as foreign key to table2. When I give like this and try to run, I'm getting an error like

SQL> Error Message: The Foreign Key TABLE1_0_SYSTEMNAMEDCONSTRAINT_TABLE2_FOREIGNKEY_NAME does not map to a primary key in table TABLE2. Each foreign key must reference a table that has a primary key made up of the same columns as specified in the reference list.


Here, I want to make that field(one among the composite primary key participants) as foreign key in my table2. Is it possible? If so how?


Thanks in advance,
Narendranath.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

Narendranath,
It is possible to do that. Do you have a one field primary key on table 2? Is it the same datatype?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Foreign key access problem