Cindy <ctmoore@uci.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
currval is defined to return the value most recently returned by nextval
in the current session. Thus, without a prior nextval, you get an error.
The reason for this is to make it useful in a situation where multiple
clients are concurrently obtaining values from the same sequence.
The 7.2 documentation set has been improved (or at least I'd like to
think so) over 7.1's description of sequence stuff. You may find that
reading
http://developer.postgresql.org/docs/postgres/datatype.html#DATATYPE-SERIALhttp://developer.postgresql.org/docs/postgres/functions-sequence.htmlhttp://developer.postgresql.org/docs/postgres/sql-createsequence.html
reduces your level of confusion. (Or not, but at least we tried...)
Note that 7.1 does not have the int8-based sequences described there,
but other than that I believe all the info carries back to 7.1.
regards, tom lane