pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Charles Hauser <chauser@duke.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: problem fetching currval of sequence
Date: Tue, 06 Aug 2002 12:16:30 -0400
Message-ID: <20533.1028650590@sss.pgh.pa.us> (raw)
In-Reply-To: <a05111b00b97594e67c38@[152.3.11.193]>
References: <a05111b00b97594e67c38@[152.3.11.193]>

Charles Hauser <chauser@duke.edu> writes:
>      foreach $id(sort keys %ACCN) {
> 	$conn->exec(
>                     "UPDATE gb SET accn_no = '$ACCN{$id}{gb}',gi_no = 
> '$ACCN{$id}{gi}' WHERE clone_id = '$ACCN{$id}{clone_id}'"
>                     );

> 	$result = $conn->exec("SELECT currval('gb_gb_id_seq');");

This isn't inserting any new row, so nextval() isn't called, so there's
nothing for currval() to work on.  Are you sure you did not mean to do
an INSERT?

If you did want an UPDATE, seems like you could do

	SELECT gb_id FROM gb WHERE clone_id = '$ACCN{$id}{clone_id}'

			regards, tom lane



view thread (12+ messages)  latest in thread

Message-ID: <20533.1028650590@sss.pgh.pa.us>
Permalink:  ../20533.1028650590@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20533.1028650590@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, chauser@duke.edu
  Subject: Re: problem fetching currval of sequence
  In-Reply-To: <20533.1028650590@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox