Re: Update with a Repeating Sequence
| От | Webb Sprague |
|---|---|
| Тема | Re: Update with a Repeating Sequence |
| Дата | |
| Msg-id | b11ea23c0810140927v275adfabtec759f4f94f8c3ba@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: Update with a Repeating Sequence (Bill Thoen <bthoen@gisnet.com>) |
| Ответы |
Re: Update with a Repeating Sequence
|
| Список | pgsql-general |
Untested ideas (beware):
Use an insert trigger that:
curr_seq := select max(seq) from foo where field_id = NEW.field_id
if curr_seq is null then NEW.seq := 0
else NEW.seq := curr_seq + 1
(You have to figure out how to build the trigger infrastructure...)
If you need to do it on a table that is already populated, let us know.
On Tue, Oct 14, 2008 at 9:21 AM, Bill Thoen <bthoen@gisnet.com> wrote:
> Grzegorz Jas'kiewicz wrote:
>>
>> alter table foo add newid sequencial;
>>
>> alter table foo drop field_id;
>>
>> alter table foo rename newid to field_id;
>>
> I can't do that; I need to preserve the field_id values.
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
В списке pgsql-general по дате отправления: