| От | Richard Huxton |
|---|---|
| Тема | Re: LAST_INSERT_ID equivalent |
| Дата | |
| Msg-id | 200306121842.28600.dev@archonet.com обсуждение исходный текст |
| Ответ на | LAST_INSERT_ID equivalent (Erik Price <eprice@ptc.com>) |
| Список | pgsql-general |
On Thursday 12 Jun 2003 6:14 pm, Erik Price wrote:
> I have a table with a SEQUENCE on it that increments the primary key (a
> BIGINT column) of the table whenever a new insert is performed.
>
> Is there a way to determine the last incremented value, so that if I do
> an insert, I can record the primary key of the record somewhere? I'm
> interested in any technique for doing this, but especially a
> JDBC-specific solution.
>
> Sorry if the answer should be obvious but I am coming from MySQL and
> trying to learn the ANSI equivalent of the MySQL features.
SELECT currval('sequence-name') - this handles multiple clients too. Not JDBC
specific.
Also look at nextval() and setval().
--
Richard Huxton
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера