| От | Ian Harding |
|---|---|
| Тема | Re: Inserting and incrementing with MAX aggregate |
| Дата | |
| Msg-id | 3A6E5373.BDF7674B@pakrat.com обсуждение исходный текст |
| Ответ на | Inserting and incrementing with MAX aggregate (Keith Perry <keith@vcsn.com>) |
| Список | pgsql-general |
Could you not: insert into events (eid,name) values ((SELECT max(eid) FROM EVENTS)+1,'server down'); It looks like it would work. It's just a subquery... Ian Keith Perry wrote: > I was wondering if this statement was still supported in 7.0.x versions > of pgSQL. I upgraded from a 6.x version where say: > > insert into events (eid,name) values (max(eid)+1,'server down'); > > works but not in the 7.x variants. > > I know that I could use the serial type for that column but in the > interest not having to rewrite the code (or dump, drop and recreate the > tables/data), I wanted to know if there was a more stand way to > incrementing a field automatically that would be fairly portable. Any > help would be appreciated. > > Keith Perry > VCSN Inc. > keith@vcsn.com > http://vcsn.com
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера