Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 863CC47580D for ; Tue, 6 Aug 2002 16:51:53 -0400 (EDT) Received: from wilson.acpub.duke.edu (wilson.acpub.duke.edu [152.3.233.69]) by postgresql.org (Postfix) with ESMTP id E435E475809 for ; Tue, 6 Aug 2002 16:51:52 -0400 (EDT) Received: from [152.3.11.193] (bglab2.botany.duke.edu [152.3.11.193]) by wilson.acpub.duke.edu (8.12.4/8.12.4/Duke-5.0.0) with ESMTP id g76KpkEc009696; Tue, 6 Aug 2002 16:51:50 -0400 (EDT) Mime-Version: 1.0 X-Sender: chauser@mail-ch.acpub.duke.edu Message-Id: In-Reply-To: <200208061135.20799.josh@agliodbs.com> References: <20611.1028651144@sss.pgh.pa.us> <200208061135.20799.josh@agliodbs.com> Date: Tue, 6 Aug 2002 16:53:24 -0400 To: josh@agliodbs.com From: Charles Hauser Subject: Re: problem fetching currval of sequence Cc: pgsql-sql@postgresql.org, tgl@sss.pgh.pa.us Content-Type: multipart/alternative; boundary="============_-1183455277==_ma============" X-Virus-Scanned: by amavisd-milter, Duke University (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/117 X-Sequence-Number: 8963 --============_-1183455277==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" 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 --============_-1183455277==_ma============ Content-Type: text/html; charset="us-ascii" Re: [SQL] problem fetching currval of sequence
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
--============_-1183455277==_ma============--