Re: problem fetching currval of sequence

From: Charles Hauser <chauser(at)duke(dot)edu>
To: josh(at)agliodbs(dot)com
Cc: pgsql-sql(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: problem fetching currval of sequence
Date: 2002-08-06 20:53:24
Message-ID: a05111b03b975e0252d02@[152.3.11.193]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Josh and Tom,

I have checked for typos, rewritten a smaller script and checked the
table setup (\d gb, see below) and
$result = $conn->exec(
"SELECT currval('gb_gb_id_seq');"
);

continues to return the error:

ERROR: gb_gb_id_seq.currval is not yet defined in this session

I know this script worked in the past, but I have not used it
recently. We are running PostgreSQL 7.1.3. It would be great if
this would work as I have several scripts which operate in a similar
manner for different TABLES, but if it won't work I'll work around it.

Suggestions for the best way to get the value for the gb_id after an INSERT?

chlamy_est=> \d gb
Table "gb"
Attribute | Type |
Modifier
-----------+-----------------------+--------------------------------------------------
gb_id | integer | not null default
nextval('"gb_gb_id_seq"'::text)
clone_id | integer |
accn | character varying(12) | not null
gi | integer | not null
Index: gb_pkey

Hmm, that sure looks like it should work. I can only counsel looking
for silly errors (typos, not running the same copy of the script that you
edited, etc). Also double-check that gb.gb_id has the column default
nextval('gb_gb_id_seq') (try psql's "\d gb" command).

--
Regards,

Chuck

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-08-06 21:26:58 Re: problem fetching currval of sequence
Previous Message Josh Berkus 2002-08-06 20:37:48 Re: problem fetching currval of sequence