Re: how to get id of last insert on a serial type?
От | Tom Lane |
---|---|
Тема | Re: how to get id of last insert on a serial type? |
Дата | |
Msg-id | 24673.1021762301@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | how to get id of last insert on a serial type? ("Robert J. Sanford, Jr." <rsanford@trefs.com>) |
Ответы |
Re: how to get id of last insert on a serial type?
Re: how to get id of last insert on a serial type? |
Список | pgsql-general |
"Robert J. Sanford, Jr." <rsanford@trefs.com> writes: > one bit that I'm currently having the largest issue with is the > @@IDENTITY property. For those not familiar with SQL Server, > performing "SELECT @@IDENTITY" allows a user to retrieve the primary > key of the last row inserted into a table (assuming the table is > using an identity column as the primary key) Use a serial column as the primary key, and then @@IDENTITY can be implemented as currval() on the associated sequence. This is more flexible than what you describe for SQL Server, because the currval can be retrieved at any later time in the same session --- as long as you don't do another insert into the same table, it's still good. regards, tom lane
В списке pgsql-general по дате отправления: