Skip site navigation (1) Skip section navigation (2)

Re: Foreign key error, please help.

From: Kumar S <ps_postgres(at)yahoo(dot)com>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Foreign key error, please help.
Date: 2005-03-09 14:46:45
Message-ID: 20050309144645.59114.qmail@web51406.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi Stephan,
Thank you very much, it was my stupid mistake.

One more question. aplogies if this is also not so
worthy question.
In a transaction does currval work only if a previous
statement defines it.  In my case I wanted to get FK
from existing currval in sample table (sample_id).
when I execute my statements in a transasction, I get
the following error. Do I have to just use a SELECT
statement here, because currval is not working? Or did
i made a mistake instead?

Thank you. 



My statement:
BEGIN TRANSACTION;
INSERT INTO
HYBRID_LABEL(sample_id,hyb_extraction_method,hyb_rna_mrna_genomicdna_extracted,hyb_amplification_pcr_rnapol,hyb_amount_nacid_labeled,hyb_label_used,hyb_label_incorporation_method,hyb_solution,hyb_blocking_agent,hyb_wash_procedure,hyb_quantity_labeled_target,hyb_time,hyb_concentration,hyb_volume,hyb_temp,hyb_instrument_desc)VALUES(currval('sample_sample_id_seq'),'NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA');



bob=> \i /home/torun/ESHSC-H1ES/test.sql
BEGIN
psql:/home//torun/ESHSC-H1ES/test.sql:2: ERROR: 
currval of sequence "sample_sample_id_seq" is not yet
defined in this session
bob=> rollback


--- Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
wrote:
> On Tue, 8 Mar 2005, Kumar S wrote:
> 
> > 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);
> 
> It looks to me like the select platform_id subselect
> is in the column
> position for seq_anno_id not the select seq_anno_id
> subselect which
> doesn't seem to be what's intended.
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 8: explain analyze is your friend
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Responses

pgsql-novice by date

Next:From: Keith WorthingtonDate: 2005-03-09 15:20:30
Subject: When are trigger function results committed
Previous:From: John DeSoiDate: 2005-03-09 13:58:31
Subject: Re: QT3 Designer Pgadmin III and PgAccess Cannot connect to PostgreSQL 7.4 database

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group