Re: Need special sequence generator

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Need special sequence generator
Дата
Msg-id 20060918105816.GC17529@a-kretschmer.de
обсуждение исходный текст
Ответ на Need special sequence generator  ("CN" <cnliou9@fastmail.fm>)
Список pgsql-general
am  Mon, dem 18.09.2006, um 15:13:10 +0800 mailte CN folgendes:
> SELECT * FROM t2 WHERE a='const_id'
>
> , then 3 records will be inserted to table t1:
>
> const_id, 1
> const_id, 2
> const_id, 3
>
> I know a PL/PGSQL function like this does the job:

You can use this:

test=# select * from t2;
 id
-----
 aaa
 bbb
 aaa
 ccc
 aaa
 ddd
(6 rows)

test=*# create sequence t2_seq;
CREATE SEQUENCE
test=*# select *, nextval('t2_seq') as foo from t2 where id = 'aaa';
 id  | foo
-----+-----
 aaa |   1
 aaa |   2
 aaa |   3
(3 rows)


(You should use a temp. sequence instead...)


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47215,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

В списке pgsql-general по дате отправления:

Предыдущее
От: "Johannes Weberhofer, Weberhofer GmbH"
Дата:
Сообщение: Re: Postgres 8.1.4 sanity_check failed on SuSE 8.2
Следующее
От: Sim Zacks
Дата:
Сообщение: Re: transaction confusion