Re: going crazy with serial type - Mailing list pgsql-general

From Cindy
Subject Re: going crazy with serial type
Date
Msg-id 7611.1012509450@attalus.tlg.uci.edu
Whole thread Raw
In response to going crazy with serial type  (Cindy <ctmoore@uci.edu>)
Responses Re: going crazy with serial type  (Darren Ferguson <darren@crystalballinc.com>)
Re: going crazy with serial type  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: going crazy with serial type  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general

OK, next question.  I'm trying to use nextval/currval and I'm getting
this:

search_info=# select currval('state_vectors_id_seq');
ERROR:  state_vectors_id_seq.currval is not yet defined in this session
search_info=# select id from state_vectors;
 id
----
  1
(1 row)


shouldn't the first select have returned 1?  The state_vectors_id_seq
is the sequence created by declaring id SERIAL in the table
state_vectors, and I've done one INSERT INTO state_vectors VALUES
(nextval('state_vectors_id_seq'), ... ); which worked fine and is
where the 1 comes from.  (I'm interested in finding out the value used
for the most recent insert, and currval seemed like a pretty painless
way of doing so.)

(I'm basing this on 4.15.2 of the postgresql faq kindly supplied
earlier.)

--CIndy

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: going crazy with serial type
Next
From: Darren Ferguson
Date:
Subject: Re: going crazy with serial type