Bill Thoen wrote:
Steve Atkins wrote:
On Oct 14, 2008, at 9:04 AM, Bill Thoen wrote:
I've got a table with repeated records that I want to make unique by
adding a sequence code of 0,1,2,...,n for each set of repeated
records. Basically, I want to turn:
field_id | seq
--+-
Steve Atkins wrote:
On Oct 14, 2008, at 9:04 AM, Bill Thoen wrote:
I've got a table with repeated records that I want to make unique by
adding a sequence code of 0,1,2,...,n for each set of repeated
records. Basically, I want to turn:
field_id | seq
--+-
1 | 0
2 |
On Oct 14, 2008, at 11:36 AM, Bill Thoen wrote:
The table exists already; all I need to do is update the sequence
code to make the records unique, but also I need each repeating set
numbered from 0 (Zero) so I can select a list of unique farm field
records where seq = 0.
"select distinct
The table exists already; all I need to do is update the sequence code
to make the records unique, but also I need each repeating set numbered
from 0 (Zero) so I can select a list of unique farm field records where
seq = 0.
I think that the suggestion to use a cursor sounds good, but I'm
conc
On Oct 14, 2008, at 9:04 AM, Bill Thoen wrote:
I've got a table with repeated records that I want to make unique by
adding a sequence code of 0,1,2,...,n for each set of repeated
records. Basically, I want to turn:
field_id | seq
--+-
1 | 0
2 | 0
3 | 0
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 t
I would probably do that in plpgsql, as a cursor
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 s
oh, sorry - you want something else. blah.
alter table foo add newid sequencial;
alter table foo drop field_id;
alter table foo rename newid to field_id;
I've got a table with repeated records that I want to make unique by
adding a sequence code of 0,1,2,...,n for each set of repeated records.
Basically, I want to turn:
field_id | seq
--+-
1 | 0
2 | 0
3 | 0
3 | 0
3 | 0
4 | 0
11 matches
Mail list logo