Re: Fw: postgresql experts please help
От | Kris Jurka |
---|---|
Тема | Re: Fw: postgresql experts please help |
Дата | |
Msg-id | Pine.BSO.4.64.0710181506040.30980@leary.csoft.net обсуждение исходный текст |
Ответ на | Re: Fw: postgresql experts please help ("Andrei Ilitchev" <andrei.ilitchev@oracle.com>) |
Ответы |
Re: Fw: postgresql experts please help
|
Список | pgsql-jdbc |
On Thu, 18 Oct 2007, Andrei Ilitchev wrote: > In the docs I discovered "select lastval()" which seems to behave exactly > like @@Identity in Sybase returning the latest nextval that was obtained in > the current session by no-matter-which sequence. > That's exactly the functionality I need - much easier to use because no need > to track the name. > > Can you think of any reason why using "select lastval()" would be a bad idea? > If you have an after trigger on the table that you're inserting into and it inserts into another table with a serial column, the lastval call will use the wrong sequence. Now this is also a problem with currval if you have a trigger that inserts into the same table, but that's an unlikely application design. Inserting into another table is something that you'll find with systems that do auditing or sometimes horizontal partitioning of a table. Kris Jurka
В списке pgsql-jdbc по дате отправления: