You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Veaceslav Chicu <cs...@infologic.fr> on 2005/11/11 17:08:27 UTC

FK fields order

create table acc.account
(
account_id integer not null,
plan_id integer not null
);
create table acc.trans
(
plan_id integer not null,
credit_id integer not null,
);
alter table acc.account add constraint account_pk primary key
(account_id, plan_id);

alter table acc.trans add constraint trans_credit_fk foreign key
(plan_id, credit_id) references acc.account (plan_id, account_id)
	on delete restrict on update restrict;

SQL Exception: Constraint 'TRANS_CREDIT_FK' is invalid: there is no
unique or primary key constraint on table 'ACC.ACCOUNT' that matches the
number and types of the columns in the foreign key.

if in trans_credit_fk I change with places plan_id, account_id, it works

it's a probleme of order, but message is wrong

best regards,
Slavic

Re: FK fields order

Posted by Mamta Satoor <ms...@gmail.com>.
Hi,
 The error message does sound misleading in this case. Can you enter a JIRA
entry to track this issue?
 Mamta

 On 11/11/05, Veaceslav Chicu <cs...@infologic.fr> wrote:
>
> create table acc.account
> (
> account_id integer not null,
> plan_id integer not null
> );
> create table acc.trans
> (
> plan_id integer not null,
> credit_id integer not null,
> );
> alter table acc.account add constraint account_pk primary key
> (account_id, plan_id);
>
> alter table acc.trans add constraint trans_credit_fk foreign key
> (plan_id, credit_id) references acc.account (plan_id, account_id)
> on delete restrict on update restrict;
>
> SQL Exception: Constraint 'TRANS_CREDIT_FK' is invalid: there is no
> unique or primary key constraint on table 'ACC.ACCOUNT' that matches the
> number and types of the columns in the foreign key.
>
> if in trans_credit_fk I change with places plan_id, account_id, it works
>
> it's a probleme of order, but message is wrong
>
> best regards,
> Slavic
>