On Wed, Feb 09, 2005 at 08:53:18AM -0800, operationsengineer1(at)yahoo(dot)com wrote:
> so, i should use nextval() if i use mitch's
> methodology of calling the id first then performing
> the insert.
Right. You can call nextval() first and then explicitly insert the
value you obtained, or you can do the insert first and let the
serial column's default expression call nextval() automatically,
and you can then find out the value it used with a subsequent call
> giving that nextval increments on a refresh, is there
> anything i need to worry about?
nextval() increments the sequence each time it's called. If you're
using the sequence values as keys, then that's what you need.
Presumably you'd only call nextval() when you're going to insert a
new record, so what's the concern?
In response to
pgsql-novice by date
|Next:||From: Michael Fuhr||Date: 2005-02-09 17:51:35|
|Subject: Re: Returning a long string (varchar from a function)|
|Previous:||From: Oisin Glynn||Date: 2005-02-09 17:30:51|
|Subject: Returning a long string (varchar from a function)|
pgsql-hackers by date
|Next:||From: Gavin M. Roy||Date: 2005-02-09 19:41:19|
|Subject: Re: PHP/PDO Database Abstraction Layer|
|Previous:||From: operationsengineer1||Date: 2005-02-09 16:53:18|
|Subject: Re: Last ID Problem|