Re: Test to see if currval will fail?
От | Oliver Elphick |
---|---|
Тема | Re: Test to see if currval will fail? |
Дата | |
Msg-id | 1039247633.1071.5.camel@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | Re: Test to see if currval will fail? (Kelly McDonald <w4kpm@adelphia.net>) |
Список | pgsql-novice |
On Fri, 2002-12-06 at 13:18, Kelly McDonald wrote: > Josh, > > Actually, I'm not really concerned about what the last value was or is, > but I am trying to find out if nextval has already been called within > the current session. so I can do something like: > > if currval_wont_puke('sequence') then > select currval('sequence') > else > select nextval('sequence') > > the part that I'm looking for is the currval_wont_puke() function. Since it is in the _current_ session, surely you can know whether you have called nextval() without asking the backend? You need to set a flag in your program when you use it or do an insert that will trigger it from a serial column, and test that. -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Go ye therefore, and teach all nations, baptizing them in the name of the Father, and of the Son, and of the Holy Ghost; Teaching them to observe all things whatsoever I have commanded you; and, lo, I am with you alway, even unto the end of the world. Amen." Matthew 28:19,20
В списке pgsql-novice по дате отправления: