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

Re: Foreign key error, please help.

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kumar S <ps_postgres(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Foreign key error, please help.
Date: 2005-03-09 15:58:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Wed, 9 Mar 2005, Kumar S wrote:

> 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?

Currval is effectively defined as the most recent value of the sequence
given from nextval in this session.  If you haven't called nextval, it
doesn't have a value to give you. But, it's session based, not transaction

In the case below what value of sample_id were you looking for? The "most
recent" one is hard to define because you could have another transaction
that's added one but hasn't committed yet.

> 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');

In response to

pgsql-novice by date

Next:From: John DeSoiDate: 2005-03-09 17:14:25
Subject: Re: QT3 Designer Pgadmin III and PgAccess Cannot connect to PostgreSQL 7.4 database
Previous:From: John DeSoiDate: 2005-03-09 15:26:26
Subject: Re: QT3 Designer Pgadmin III and PgAccess Cannot connect to PostgreSQL 7.4 database

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