| От | Russell Smith |
|---|---|
| Тема | Re: Using sequence name depending on other column |
| Дата | |
| Msg-id | 200503131711.34700.mr-russ@pws.com.au обсуждение исходный текст |
| Ответ на | Re: Using sequence name depending on other column (Bruno Wolff III <bruno@wolff.to>) |
| Список | pgsql-general |
On Sun, 13 Mar 2005 02:59 pm, Bruno Wolff III wrote: > On Sat, Mar 12, 2005 at 23:05:41 +0200, > Andrus Moor <eetasoft@online.ee> wrote: > > I have table containing different types of documents (type A, B and C). > > > > Each document type must have separate sequential ID starting at 1 > > > > ID of first inserted record of type A must be set to 1 > > ID of first inserted record of type B must be also set to 1 > > ID of second record of type A must be set to 2 > > etc. > If you are happy with the fact that a sequence may leave a whole in the numbers. You are probably best to no set a default value for an integer, or big integer. Then run a before trigger for each row. That trigger will assign a value to the column based on the value given for the type. Regards Russell Smith
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера