From: | "Webb Sprague" <webb(dot)sprague(at)gmail(dot)com> |
---|---|
To: | "Bill Thoen" <bthoen(at)gisnet(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Update with a Repeating Sequence |
Date: | 2008-10-14 16:27:34 |
Message-ID: | b11ea23c0810140927v275adfabtec759f4f94f8c3ba@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)gisnet(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Atkins | 2008-10-14 16:30:50 | Re: Update with a Repeating Sequence |
Previous Message | Grzegorz Jaśkiewicz | 2008-10-14 16:25:46 | Re: Update with a Repeating Sequence |