Subject | Re: [firebird-support] Self Reference Error? Bug? |
---|---|
Author | Helen Borrie |
Post date | 2004-01-20T07:45:50Z |
At 07:27 AM 20/01/2004 +0000, you wrote:
exist in the database. At the point where you are trying to do it, the
table and its primary key are still defined only within your unfinished
transaction.
Change your script to:
create table ExampleTable (
code integer not null primary key,
name varchar(100) not null unique,
parent integer);
commit;
alter table ExampleTable
add constraint fk_parent
foreign key (parent) references ExampleTable(code);
commit;
/h
>Hi,Nope. You can't define the foreign key until the table and its primary key
>
>I am trying to execute the following SQL which has self-reference:
>
> create table ExampleTable (
> code integer not null primary key,
> name varchar(100) not null unique,
> parent integer,
>
> foreign key (parent) references ExampleTable(code)
> );
>
>And, this throws an error like:
>
>fmSQLEditor.Query:
>This operation is not defined for system tables.
>unsuccessful metadata update.
>object EXAMPLETABLE is in use .
>
>Is this a bug?
exist in the database. At the point where you are trying to do it, the
table and its primary key are still defined only within your unfinished
transaction.
Change your script to:
create table ExampleTable (
code integer not null primary key,
name varchar(100) not null unique,
parent integer);
commit;
alter table ExampleTable
add constraint fk_parent
foreign key (parent) references ExampleTable(code);
commit;
/h