Cindy <ctmoore(at)uci(dot)edu> writes:
> 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
You need to do an explicit or implicit 'nextval' in a transaction
before 'currval' will work in that transaction. So you can do:
BEGIN WORK;
INSERT INTO mytable (a, b) VALUES (1,2);
SELECT nextval('mytable_id_seq');
<do something with it>
COMMIT WORK;
-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863