From: | Justin Clift <justin(at)postgresql(dot)org> |
---|---|
To: | Cindy <ctmoore(at)uci(dot)edu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: going crazy with serial type |
Date: | 2002-01-31 22:01:22 |
Message-ID: | 3C59BEB2.F1B56106@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Cindy,
I'd also recommend you take a look at :
http://techdocs.postgresql.org/college/001_sequences/
As this is a CBT which explains things pretty well.
:-)
Regards and best wishes,
Justin Clift
Cindy wrote:
>
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-01-31 22:01:34 | Re: going crazy with serial type |
Previous Message | mordicus | 2002-01-31 21:56:12 | Re: going crazy with serial type |