Re: last inserted raw (identity)

Поиск
Список
Период
Сортировка
От Ron Johnson
Тема Re: last inserted raw (identity)
Дата
Msg-id 1059795782.22384.116.camel@haggis
обсуждение исходный текст
Ответ на Re: last inserted raw (identity)  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: last inserted raw (identity)  (Martijn van Oosterhout <kleptog@svana.org>)
Re: last inserted raw (identity)  (nolan@celery.tssi.com)
Список pgsql-general
On Fri, 2003-08-01 at 22:27, Martijn van Oosterhout wrote:
> 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().

What if his PK isn't a sequence?

--
+-----------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net             |
| Jefferson, LA  USA                                              |
|                                                                 |
| "I'm not a vegetarian because I love animals, I'm a vegetarian  |
|  because I hate vegetables!"                                    |
|    unknown                                                      |
+-----------------------------------------------------------------+



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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: last inserted raw (identity)
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: plPHP -- sort of an announcement.. but not commercial