Search Postgresql Archives

Re: Update with a Repeating Sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx> 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@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux