Re: Last ID Problem
От | Michael Fuhr |
---|---|
Тема | Re: Last ID Problem |
Дата | |
Msg-id | 20050209173828.GA6212@winnie.fuhr.org обсуждение исходный текст |
Ответ на | Re: Last ID Problem (<operationsengineer1@yahoo.com>) |
Список | pgsql-novice |
On Wed, Feb 09, 2005 at 08:53:18AM -0800, operationsengineer1@yahoo.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 to currval(). > 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? -- Michael Fuhr http://www.fuhr.org/~mfuhr/
В списке pgsql-novice по дате отправления: