Re: nextval/dbi question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: harrold(at)sage(dot)che(dot)pitt(dot)edu
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: nextval/dbi question
Date: 2001-08-05 23:09:31
Message-ID: 7165.997052971@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

harrold(at)sage(dot)che(dot)pitt(dot)edu writes:
> i want to insert data into a table that has a serialized key. then i want
> the value of the key for the row i just inserted. from the stuff i read
> on the net i though i was supposed to run the nextval command first then
> preform the insert.

That is about the simplest and most obvious way to do it, IMHO. What
you're missing is that you have to explicitly insert the value you got
from nextval() into the key column. If you allow the key column to be
defaulted in the INSERT, then nextval() gets run again.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message harrold 2001-08-06 00:20:16 Re: nextval/dbi question
Previous Message harrold 2001-08-05 23:06:54 Re: nextval/dbi question