pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedPROBLEM WITH FOREIGN KEY
7+ messages / 6 participants
[nested] [flat]
* PROBLEM WITH FOREIGN KEY
@ 2003-03-18 16:32 Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-18 16:50 ` Re: PROBLEM WITH FOREIGN KEY Donald Fraser <demolish@cwgsy.net>
0 siblings, 1 reply; 7+ messages in thread
From: Mario Alberto Soto Cordones @ 2003-03-18 16:32 UTC (permalink / raw)
To: pgsql-admin
hi.
i have a big problem...
i have created a 2 table cumacar and cumaasi,
the structure is
CUMACAR
cuidcar char(2)
cucodcar numeric(2)
cudescar varchar(35)
cuempcar numeric(2)
primary key (cucodcar, cuempcar)
CUMAASI
cucodasi numeric 3
cudesasi varchar 60
cucarasi numeric 2
cuempasi numeric 2
primary key (cucarasi, cucodasi, cuempasi)
i try create a foreing key and say:
Error - /var/www/html/phpPgAdmin/sql.php -- Line: 112
PostgreSQL ha dicho: ERROR: cumaasi_fk_cumacar referential integrity
violation - key referenced from cumaasi not found in cumacar
Your query:
ALTER TABLE cumaasi
ADD CONSTRAINT cumaasi_fk_cumacar
FOREIGN KEY(cucarasi, cuempasi)
REFERENCES
cumacar (cucodcar, cuempcar)
PLEASE HELP ME
sorry for my englis... i live in chile...
thank you
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PROBLEM WITH FOREIGN KEY
2003-03-18 16:32 PROBLEM WITH FOREIGN KEY Mario Alberto Soto Cordones <mario_soto@compuall.cl>
@ 2003-03-18 16:50 ` Donald Fraser <demolish@cwgsy.net>
0 siblings, 0 replies; 7+ messages in thread
From: Donald Fraser @ 2003-03-18 16:50 UTC (permalink / raw)
To: pgsql-admin; Mario Alberto Soto Cordones <mario_soto@compuall.cl>
>> PostgreSQL ha dicho: ERROR: cumaasi_fk_cumacar referential integrity violation - key referenced from cumaasi not found in cumacar
The message is telling you that it cannot create the constraint because data in the two tables causes a referential integrity violation.
That is there is data in a record for table CUMAASI for columns cucarasi and cuempasi that cannot be matched to a record for table CUMACAR for columns cucodcar and cuempcar.
Regards
Donald Fraser
----- Original Message -----
From: Mario Alberto Soto Cordones
To: pgsql-admin@postgresql.org
Sent: Tuesday, March 18, 2003 4:32 PM
Subject: [ADMIN] PROBLEM WITH FOREIGN KEY
hi.
i have a big problem...
i have created a 2 table cumacar and cumaasi,
the structure is
CUMACAR
cuidcar char(2)
cucodcar numeric(2)
cudescar varchar(35)
cuempcar numeric(2)
primary key (cucodcar, cuempcar)
CUMAASI
cucodasi numeric 3
cudesasi varchar 60
cucarasi numeric 2
cuempasi numeric 2
primary key (cucarasi, cucodasi, cuempasi)
i try create a foreing key and say:
Error - /var/www/html/phpPgAdmin/sql.php -- Line: 112
PostgreSQL ha dicho: ERROR: cumaasi_fk_cumacar referential integrity
violation - key referenced from cumaasi not found in cumacar
Your query:
ALTER TABLE cumaasi
ADD CONSTRAINT cumaasi_fk_cumacar
FOREIGN KEY(cucarasi, cuempasi)
REFERENCES
cumacar (cucodcar, cuempcar)
PLEASE HELP ME
sorry for my englis... i live in chile...
thank you
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
^ permalink raw reply [nested|flat] 7+ messages in thread
* problem with foreign key
@ 2010-09-05 20:17 Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-05 20:38 ` Re: problem with foreign key Szymon Guz <mabewlun@gmail.com>
2010-09-05 20:40 ` Re: problem with foreign key Bèrto ëd Sèra <berto.d.sera@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Ljubomir Erdeljan @ 2010-09-05 20:17 UTC (permalink / raw)
To: pgsql-admin
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.
kindly regards
ljubomir erdeljan
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: problem with foreign key
2010-09-05 20:17 problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
@ 2010-09-05 20:38 ` Szymon Guz <mabewlun@gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: Szymon Guz @ 2010-09-05 20:38 UTC (permalink / raw)
To: Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>; +Cc: 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: problem with foreign key
2010-09-05 20:17 problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
@ 2010-09-05 20:40 ` Bèrto ëd Sèra <berto.d.sera@gmail.com>
2010-09-05 20:49 ` Re: problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
1 sibling, 1 reply; 7+ messages in thread
From: Bèrto ëd Sèra @ 2010-09-05 20:40 UTC (permalink / raw)
To: ; +Cc: pgsql-admin
An immediate question: did you check that Key (docuuserid)=(8415) is
actually present in table "trade"?
Bèrto
On 5 September 2010 23: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.
>
>
>
> kindly regards
>
> ljubomir erdeljan
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>
--
==============================
Constitution du 24 juin 1793 - Article 35. - Quand le gouvernement viole les
droits du peuple, l'insurrection est, pour le peuple et pour chaque portion
du peuple, le plus sacré des droits et le plus indispensable des devoirs.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: problem with foreign key
2010-09-05 20:17 problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-05 20:40 ` Re: problem with foreign key Bèrto ëd Sèra <berto.d.sera@gmail.com>
@ 2010-09-05 20:49 ` Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-07 00:22 ` Re: problem with foreign key Lew <noone@lewscanon.com>
0 siblings, 1 reply; 7+ messages in thread
From: Ljubomir Erdeljan @ 2010-09-05 20:49 UTC (permalink / raw)
To: pgsql-admin
This relate to different column names
docuuserid is column in porder1 but relate to tradeid in trade.
Thank you,
On 05/09/2010 22:40, Bèrto ëd Sèra wrote:
> An immediate question: did you check that Key (docuuserid)=(8415) is
> actually present in table "trade"?
>
> Bèrto
>
> On 5 September 2010 23:17, Ljubomir Erdeljan
> <ljubomir.erdeljan@chello.at <mailto: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.
>
>
>
> kindly regards
>
> ljubomir erdeljan
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org
> <mailto:pgsql-admin@postgresql.org>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>
>
>
>
> --
> ==============================
> Constitution du 24 juin 1793 - Article 35. - Quand le gouvernement
> viole les droits du peuple, l'insurrection est, pour le peuple et pour
> chaque portion du peuple, le plus sacré des droits et le plus
> indispensable des devoirs.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: problem with foreign key
2010-09-05 20:17 problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-05 20:40 ` Re: problem with foreign key Bèrto ëd Sèra <berto.d.sera@gmail.com>
2010-09-05 20:49 ` Re: problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
@ 2010-09-07 00:22 ` Lew <noone@lewscanon.com>
0 siblings, 0 replies; 7+ messages in thread
From: Lew @ 2010-09-07 00:22 UTC (permalink / raw)
To: pgsql-admin
Please do not top-post.
Bèrto ëd Sèra wrote:
>> An immediate question: did you check that Key (docuuserid)=(8415) is
>> actually present in table "trade"?
Ljubomir Erdeljan wrote:
> This relate to different column names
> docuuserid is column in porder1 but relate to tradeid in trade.
You missed the point. Did you check that the key is present in "trade"?
IOW, is there a row in "trade" with "tradeid" equal to 8415? If not, you
cannot create the foreign key because the item in "porder1" cannot point to it.
--
Lew
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2010-09-07 00:22 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18 16:32 PROBLEM WITH FOREIGN KEY Mario Alberto Soto Cordones <mario_soto@compuall.cl>
2003-03-18 16:50 ` Donald Fraser <demolish@cwgsy.net>
2010-09-05 20:17 problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-05 20:38 ` Re: problem with foreign key Szymon Guz <mabewlun@gmail.com>
2010-09-05 20:40 ` Re: problem with foreign key Bèrto ëd Sèra <berto.d.sera@gmail.com>
2010-09-05 20:49 ` Re: problem with foreign key Ljubomir Erdeljan <ljubomir.erdeljan@chello.at>
2010-09-07 00:22 ` Re: problem with foreign key Lew <noone@lewscanon.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox