| From: | Doug McNaught <doug(at)wireboard(dot)com> |
|---|---|
| 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 20:51:48 |
| Message-ID: | m3bsfatfa3.fsf@varsoon.denali.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Darren Ferguson | 2002-01-31 20:53:47 | Re: going crazy with serial type |
| Previous Message | Stephan Szabo | 2002-01-31 20:51:19 | Re: going crazy with serial type |