| От | Joe Conway |
|---|---|
| Тема | Re: Value of sequence last inserted |
| Дата | |
| Msg-id | 3E6CC161.1010403@joeconway.com обсуждение исходный текст |
| Ответ на | Value of sequence last inserted (bryan@flyingiranch.com) |
| Список | pgsql-novice |
bryan@flyingiranch.com wrote: > I have a sequence that I am using on a field that I am using for the ID > of an item in a table. After an insert to that table, I need to insert > into two other tables using the same ID - does the initial insert > somehow return the value of the sequence that was used? I know it may > not be reliable to do, say "SELECT MAX ID FROM"..., so how can I assure > that I have the right ID for my other inserts? Should I just do the set > of inserts as a transaction? > See: http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/functions-sequence.html specifically look at currval(). HTH, Joe
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера