From: | Miroslav Šulc <miroslav(dot)sulc(at)startnet(dot)cz> |
---|---|
To: | |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Most efficient way to hard-sort records |
Date: | 2006-05-09 08:54:19 |
Message-ID: | 446058BB.5090201@startnet.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi PFC,
the generate_series() seems to be the right thing I need in my scenario
but I didn't figure out how to create a SELECT stattement that will
contain sorted main_table.id in first column and generated series in
second column which I would use to update the main_table.position. Is it
possible? How can I do that? Or is there another approach to employ
generate_series()?
Miroslav Šulc
PFC napsal(a):
>
>> Another version along that line ?
>>
>> # create sequence counterseq start 1;
>> -- (set/reset whenever a counter is needed)
>>
>> # select main_table.*, nextval('counterseq') as position2
>> into sorted_main_table
>> from main_table, keytable where main_table.id =
>> keytable.main_table_id
>> order by value;
>
> You could also use generate_series(), but I don't know if it can
> generate unbounded series...
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
Attachment | Content-Type | Size |
---|---|---|
miroslav.sulc.vcf | text/x-vcard | 360 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2006-05-10 03:24:56 | Re: Most efficient way to hard-sort records |
Previous Message | Peter Eisentraut | 2006-05-08 21:23:54 | Re: Postgres 8.1 sequences and 'CALL'-syntax |