Re: The old Insert and retrieving your Serial problem in

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: The old Insert and retrieving your Serial problem in
Дата
Msg-id E0BFC501-9DA6-4ECA-9A58-3F49888ABCF2@nasby.net
обсуждение исходный текст
Ответ на Re: The old Insert and retrieving your Serial problem in  (John McCawley <nospam@hardgeus.com>)
Список pgsql-general
I think it is. There are also functions that will tell you what the
sequence for a given field in a given table is (might also be new in
8.1, but you could probably recreate them yourself).

Also, in 8.2 you'll be able to do INSERT ... RETURNING, which can
return the id directly back to you.

On Nov 14, 2006, at 3:47 PM, John McCawley wrote:
> That looks like the solution to my problem, thanks!...I tried
> running it on my 8.0.8 server, but it wasn't found, I assume that's
> an 8.1 only function?
>
> Martijn van Oosterhout wrote:
>
>> On Tue, Nov 14, 2006 at 03:54:42PM -0600, John McCawley wrote:
>>
>>> I am once again dealing with that age old problem of retrieving
>>> the value of your inserted serial field in VB.  I am fully aware
>>> that I can manually pull the currval or nextval from my sequence,
>>> but I consider having to manually deal with an auto-generated
>>> database object an *extremely* inelegant solution.
>>>
>>
>> Maybe you're looking for lastval()?
>>
>> http://www.postgresql.org/docs/8.1/interactive/functions-
>> sequence.html
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)





В списке pgsql-general по дате отправления:

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: Using SAN Splits to instantly copy a DB
Следующее
От: "Ardian Xharra"
Дата:
Сообщение: Re: Data corruption