Re: Need special sequence generator

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Need special sequence generator
Date: 2006-09-18 10:58:16
Message-ID: 20060918105816.GC17529@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2006-09-18 11:57:05 Re: transaction confusion
Previous Message Johannes Weberhofer, Weberhofer GmbH 2006-09-18 10:27:02 Re: Postgres 8.1.4 sanity_check failed on SuSE 8.2