Re: problem with foreign key

Поиск
Список
Период
Сортировка
От Szymon Guz
Тема Re: problem with foreign key
Дата
Msg-id AANLkTiknXbdLo1PtO=3JqPjFi5vhVWQusKJuYUybv7uT@mail.gmail.com
обсуждение исходный текст
Ответ на problem with foreign key  (Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>)
Список pgsql-admin
On 5 September 2010 22:17, Ljubomir Erdeljan <ljubomir.erdeljan@chello.at> wrote:
 hi group,

trying to create foreign key:

ALTER TABLE porder1 ADD CONSTRAINT order_exist
FOREIGN KEY (docuuserid) REFERENCES trade(tradeid) ON DELETE RESTRICT;

column docuuserid is integer in porder1
column tradeid    is serial  in trade and belong to primary key (single column)

getting In EMS PostgreSQL
ERROR:  insert or update on table "porder1" violates foreign key constraint "order_exist"
DETAIL: Key (docuuserid)=(8415) is not present in table "trade".

In PostgreSQL  Code Factory
SQL Error: ERROR:  insert or update on table "porder1" violates foreign key constraint "order_exist"
DETAIL:    Key (docuuserid)=(8415) is not present in table "trade".

postgresql 8.4.4-1 on windows 7 ultimate 64 bit standard installation

I'm not able to figure out what should be a problem.


During the foreign key creation, database checks if all rows are correct, and they are not. There is a row in the porder1 table where field docuuserid = 8415 and there is no row in the table trader where tradeid=8415.

regards
Szymon Guz

В списке pgsql-admin по дате отправления:

Предыдущее
От: Ljubomir Erdeljan
Дата:
Сообщение: problem with foreign key
Следующее
От: Bèrto ëd Sèra
Дата:
Сообщение: Re: problem with foreign key