Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91B9947595D for ; Tue, 6 Aug 2002 12:48:29 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E5542475947 for ; Tue, 6 Aug 2002 12:48:28 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g76GmWVk020829; Tue, 6 Aug 2002 12:48:32 -0400 (EDT) To: Charles Hauser Cc: pgsql-sql@postgresql.org Subject: Re: problem fetching currval of sequence In-reply-to: References: <20533.1028650590@sss.pgh.pa.us> Comments: In-reply-to Charles Hauser message dated "Tue, 06 Aug 2002 12:43:32 -0400" Date: Tue, 06 Aug 2002 12:48:32 -0400 Message-ID: <20828.1028652512@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/107 X-Sequence-Number: 8953 Charles Hauser writes: > Quite right, I did mean to do an INSERT. Changing the script to do > so though I still get the error: > ERROR: gb_gb_id_seq.currval is not yet defined in this session. > foreach $id(sort keys %ACCN) { > $conn->exec( > "INSERT INTO gb (clone_id,accn,gi) > VALUES ( '$ACCN{$id}{clone_id}','$ACCN{$id}{gb}','$ACCN{$id}{gi}')"; > ); > $result = $conn->exec("SELECT currval('gb_gb_id_seq');"); > die $conn->errorMessage unless PGRES_TUPLES_OK eq > $result->resultStatus; > $gb_id = $result->fetchrow; > $ACCN{$id}{gb_id} = $gb_id; > } 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, tom lane