Re: Stuck on Foreign Keys

From: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
To: Chester <chester(at)hica(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stuck on Foreign Keys
Date: 2007-09-20 07:49:40
Message-ID: e373d31e0709200049m70edcae5k5ae823c926c3869@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20/09/2007, Chester <chester(at)hica(dot)com(dot)au> wrote:
> Hi
>
> I have a question regarding foreign keys, I just cannot get it to create
> them for me....I must be doing something wrong but I have no idea what
> that might be :)
>
> I have a table "clients"
>
> clientID (primary)
> ticode
> Firstname
> SecondName
>
> I have a second table "titles"
>
> ticode (primary)
> Title
>
> I am trying to create a foreign key on TIcode "clients" table as in below,
>
> ALTER TABLE clients ADD CONSTRAINT the_title FOREIGN KEY (ticode)
> REFERENCES titles (ticode) ;
>
> I keep getting this error
>
> ERROR: insert or update on table "clients" violates foreign key
> constraint "the_title"
> DETAIL: Key (ticode)=( ) is not present in table "titles".
>
> Sorry, I have no idea where I am going wrong...Any help would be great

The ticode that you are trying to insert into clients -- does this
ticode exist in the table titles?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2007-09-20 08:15:39 Re: Postgresql and SSL
Previous Message Hannes Dorbath 2007-09-20 07:11:32 Re: about pgpool question