Foreign key error, please help.

From: Kumar S <ps_postgres(at)yahoo(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-novice(at)postgresql(dot)org
Subject: Foreign key error, please help.
Date: 2005-03-08 14:48:14
Message-ID: 20050308144814.6263.qmail@web51410.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Dear group,

when I try to insert a statement :

INSERT INTO
processed_data(exp_id,seq_anno_id,cel_id,proc_symbol,proc_exprs,proc_pval)VALUES((currval('experiment_exp_id_seq')),(SELECT
platform_id from platform where platform_filename =
'RGeo-ESHSC-H1ES1-1a-U133A'),(SELECT seq_anno_id FROM
sequence_annotation, genechip WHERE
sequence_annotation.seq_probeset_id =
'AFFX-r2-Ec-bioB-M_at'AND
sequence_annotation.genechip_id = genechip.genechip_id
AND genechip.genechip_array =
'U133A'),'AFFX-r2-Ec-bioB-M_at',6.419,0.1671675);

I get a weird error:

Now I took the :
bob=> (SELECT seq_anno_id FROM sequence_annotation,
genechip WHERE sequence_annotation.seq_probeset_id =
'AFFX-r2-Ec-bioB-M_at'AND
sequence_annotation.genechip_id = genechip.genechip_id
AND genechip.genechip_array = 'U133A');
seq_anno_id
-------------
45881
(1 row)

Why is it so?

When I give the select statement seperate I get the
answer and when I embed the same in INSERT statement I
get the following error:

ERROR: insert or update on table "processed_data"
violates foreign key constraint "$3"
DETAIL: Key (seq_anno_id)=(6) is not present in table
"sequence_annotation".

My sequence_annotation table:
seq_anno_id | integer |
not null default
nextval('public.sequence_annotation_seq_anno_id_
seq'::text)
seq_probeset_id | character varying(15000) |
seq_source | character varying(15000) |
.......................|.........................

Indexes:
"sequence_annotation_pkey" primary key, btree
(seq_anno_id)
Foreign-key constraints:
"$1" FOREIGN KEY (genechip_id) REFERENCES
genechip(genechip_id)

My Processed data table:
proc_id | integer | not null
default
nextval('public.processed_data_proc_id_seq'::text)
exp_id | integer |
seq_anno_id | integer |
cel_id | integer |
proc_symbol | character varying(100) |
proc_exprs | real |
proc_pval | real |
Indexes:
"processed_data_pkey" primary key, btree (proc_id)
Foreign-key constraints:
"$2" FOREIGN KEY (exp_id) REFERENCES
experiment(exp_id)
"$3" FOREIGN KEY (seq_anno_id) REFERENCES
sequence_annotation(seq_anno_id)
"$4" FOREIGN KEY (cel_id) REFERENCES cel(cel_id)

Sorry if the wrapping of text makes it uncomfortable
for you to read.



__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2005-03-08 14:57:15 Re: Foreign key error, please help.
Previous Message David 2005-03-08 14:26:57 Re: Getting started - Interfacing questions