| From: | Charles Hauser <chauser(at)duke(dot)edu> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | problem fetching currval of sequence |
| Date: | 2002-08-06 15:14:49 |
| Message-ID: | a05111b00b97594e67c38@[152.3.11.193] |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joerg Hessdoerfer | 2002-08-06 15:24:53 | Re: Table design question... |
| Previous Message | Dan Langille | 2002-08-06 14:59:10 | Re: Transitive Closure |