Thread: Data Issue

Data Issue

From
Somnath Som
Date:

When trying to insert data in a table then getting below error, someone can guide me please how to resolve the issue.

 

Error: insert or update on table "site" violates foreign key constraint "reg_fkey"
DETAIL:  Key (region)=() is not present in table "region".
Traceback (most recent call last):

 

 

Re: Data Issue

From
Kashif Zeeshan
Date:
Hi  

It's a foreign key error.
In Your case the Region Table is the Source Table from where the Site Table is linked with Foreign Key
And you are inserting data in the Site table where the Foreign Key Column (region) has no data in the Parent Table Region.

Regards
Kashif Zeeshan

On Sun, Jul 21, 2024 at 9:47 PM Somnath Som <somnath.som@ericsson.com> wrote:

When trying to insert data in a table then getting below error, someone can guide me please how to resolve the issue.

 

Error: insert or update on table "site" violates foreign key constraint "reg_fkey"
DETAIL:  Key (region)=() is not present in table "region".
Traceback (most recent call last):

 

 

Re: Data Issue

From
Holger Jakobs
Date:
Every site has to be within a region. The column region of the row you try to insert into the table "site" doesn't contain a value.


Am 21. Juli 2024 18:47:06 MESZ schrieb Somnath Som <somnath.som@ericsson.com>:

When trying to insert data in a table then getting below error, someone can guide me please how to resolve the issue.

 

Error: insert or update on table "site" violates foreign key constraint "reg_fkey"
DETAIL:  Key (region)=() is not present in table "region".
Traceback (most recent call last):

 

 

Re: Data Issue

From
Laurenz Albe
Date:
On Sun, 2024-07-21 at 19:14 +0200, Holger Jakobs wrote:
> Am 21. Juli 2024 18:47:06 MESZ schrieb Somnath Som <somnath.som@ericsson.com>:
> > When trying to insert data in a table then getting below error, someone can guide me please how to resolve the
issue.
> >  
> > Error: insert or update on table "site" violates foreign key constraint "reg_fkey"
> > DETAIL:  Key (region)=() is not present in table "region".
> > Traceback (most recent call last):
>
> Every site has to be within a region. The column region of the row you try to insert into the table "site" doesn't
containa value. 

I'd say it contains an empty string, and there is no such region.

Yours,
Laurenz Albe