Return value of 'serial' column on insert

Поиск
Список
Период
Сортировка
Искать
От
Madison Kelly
Тема
Return value of 'serial' column on insert
Дата
Msg-id
41F87D9D.6020204@alteeve.com
Список
Дерево обсуждения
Return value of 'serial' column on insert Madison Kelly <linux@alteeve.com>
Re: Return value of 'serial' column on insert Bruno Wolff III <bruno@wolff.to>
Hi all,

   I have several tables with an 'id' column which is a simple 'serial 
unique' type. Often when I insert a record the next thing I need is to 
add or edit another table elsewhere using the ID of the entry I just 
added. Currently what I do is:

SELECT _id FROM 
ORDER BY
_id DESC LIMIT 1; and assume (safely thus far) that the returned value is the one I just created. Obviously this is bulky and, should by chance another column be added in that time between insert and read, I would get the wrong value. Is there a way to do an INSERT (in perl, btw) where pgSQL returns the value just created by the same INSERT? Thanks! Madison -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Madison Kelly (Digimer) TLE-BU, The Linux Experience; Back Up http://tle-bu.thelinuxexperience.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
В списке pgsql-general по дате отправления
От: Bruno Wolff III
Дата:
Сообщение: Re: self-join on subselect
От: Max
Дата:
FAQ