Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BBF70476265 for ; Tue, 6 Aug 2002 11:13:15 -0400 (EDT) Received: from eddings.acpub.duke.edu (eddings.acpub.duke.edu [152.3.233.76]) by postgresql.org (Postfix) with ESMTP id 1272F476233 for ; Tue, 6 Aug 2002 11:13:15 -0400 (EDT) Received: from [152.3.11.193] (bglab2.botany.duke.edu [152.3.11.193]) by eddings.acpub.duke.edu (8.12.4/8.12.4/Duke-5.0.0) with ESMTP id g76FDGZ2010465; Tue, 6 Aug 2002 11:13:17 -0400 (EDT) Mime-Version: 1.0 X-Sender: chauser@mail-ch.acpub.duke.edu Message-Id: Date: Tue, 6 Aug 2002 11:14:49 -0400 To: pgsql-sql@postgresql.org From: Charles Hauser Subject: problem fetching currval of sequence Content-Type: multipart/alternative; boundary="============_-1183475592==_ma============" X-Virus-Scanned: by amavisd-milter, Duke University (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/92 X-Sequence-Number: 8938 --============_-1183475592==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" Hi, I have a script to load values into a table (gb) which contains a SEQUENCE ('gb_id'). For each entry into TABLE gb I need the value of 'gb_gb_id_seq' to update a relational table. I am getting the following error msg: ERROR: gb_gb_id_seq.currval is not yet defined in this session. If anyone knows why this is not working I would appreciate suggestions. CREATE TABLE "gb" ( "gb_id" int4 DEFAULT nextval('"gb_gb_id_seq"'::text) NOT NULL, "clone_id" int4, "accn" varchar(12) NOT NULL, "gi" int4 NOT NULL, CONSTRAINT "gb_pkey" PRIMARY KEY ("gb_id") ); 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');"); die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus; $gb_id = $result->fetchrow; $ACCN{$id}{gb_id} = $gb_id; } -- Regards, Charles --============_-1183475592==_ma============ Content-Type: text/html; charset="us-ascii" problem fetching currval of sequence
Hi,

I have a script to load values into a table (gb) which contains a SEQUENCE ('gb_id').  For each entry into TABLE gb I need the value of 'gb_gb_id_seq' to update a relational table.   I am getting the following error msg:
                ERROR: gb_gb_id_seq.currval is not yet defined in this session.

If anyone knows why this is not working I would appreciate suggestions.



CREATE TABLE "gb" (
   "gb_id" int4 DEFAULT nextval('"gb_gb_id_seq"'::text) NOT NULL,
   "clone_id" int4,
   "accn" varchar(12) NOT NULL,
   "gi" int4 NOT NULL,
   CONSTRAINT "gb_pkey" PRIMARY KEY ("gb_id")
);

    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');");
        die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
        $gb_id = $result->fetchrow;
        $ACCN{$id}{gb_id} = $gb_id;
    }

-- 
Regards,

        Charles
--============_-1183475592==_ma============--