Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Foreign key constraint error

Author  Topic 

monkeyfunkster
Starting Member

1 Post

Posted - 2008-04-09 : 14:19:27
Hi all, I'm new here so I hope this is the right place to post!!

I'm having a really big problem trying to make a table. I'm not new to the coding, but I'm no expert either.... as far as I can see I haven't done anything wrong...

I have many tables, but the first two are JobDetails and Promotions... in JobDetails, there is a primary key Job which needs to link to Promotions as a foreign key.... here is my code and errors, I'd really appreciate some help...


create table JOBDETAIL
(Job varchar2(15) primary key,
Dept varchar2(10) not null,
Salary number(7) not null);


create table PROMOTION
(PCID number(6) primary key,
PDate date,
Constraint fkey_p1 foreign key (Job) references JOBDETAIL(Job));

ERROR at line 4:
ORA-00904: "Job": invalid identifier



... any help would be appreciated, this is quite important... thank you!!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-09 : 14:35:26
You havent defined the Job column in your PROMOTION table.make it like this

create table PROMOTION
(PCID number(6) primary key,
PDate date,
Job Constraint fkey_p1 foreign key references JOBDETAIL(Job));

Also keep in mind that this is a MS SQL Server forum. Please post your oracle doubts in some oracle forums in future to get quick help.
Go to Top of Page
   

- Advertisement -