| От | Martijn van Oosterhout |
|---|---|
| Тема | Re: last inserted raw (identity) |
| Дата | |
| Msg-id | 20030802032752.GC27983@svana.org обсуждение исходный текст |
| Ответ на | last inserted raw (identity) (b b <hell_wild_hot2@yahoo.com>) |
| Ответы |
Re: last inserted raw (identity)
|
| Список | pgsql-general |
On Fri, Aug 01, 2003 at 04:25:05PM -0700, b b wrote:
>
> Is there an environment variable that returns the
> primary key of the last inserted row. This is usefull
> if you insert a rwo and need the primary key to insert
> it into another table as a foreign key.
>
> In MS-SQL that is equivalent to @@identity variable:
> insert into organization ('org name', ....)
> insert into contact (@@identity, 'contact name'
> .....)
> Here Identity is the organization's ID that is needed
> as a foreign key in contact table.
See currval() and nextval().
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> "All that is needed for the forces of evil to triumph is for enough good
> men to do nothing." - Edmond Burke
> "The penalty good people pay for not being interested in politics is to be
> governed by people worse than themselves." - Plato
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера