X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DAFF753B49 for ; Tue, 26 Apr 2005 00:13:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42789-01 for ; Tue, 26 Apr 2005 03:13:52 +0000 (GMT) Received: from nitrogenio.carvalhaes.net (unknown [200.175.206.50]) by svr1.postgresql.org (Postfix) with ESMTP id BC3AC53497 for ; Tue, 26 Apr 2005 00:13:15 -0300 (ADT) Received: from [192.168.0.199] ([192.168.0.199]) (authenticated bits=0) by nitrogenio.carvalhaes.net (8.13.3/8.13.1) with ESMTP id j3Q33ll8002213 for ; Tue, 26 Apr 2005 00:03:48 -0300 Message-ID: <426DB1A0.2000604@carvalhaes.net> Date: Tue, 26 Apr 2005 00:12:32 -0300 From: Rodrigo Carvalhaes Reply-To: grupos@carvalhaes.net User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-sql@postgresql.org Subject: UPDATE WITH ORDER BY References: <20050425202406.GA3289@winnie.fuhr.org> In-Reply-To: <20050425202406.GA3289@winnie.fuhr.org> Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Triade-MailScanner-Information: Por favor, entre em contato para obter detalhes X-Triade-MailScanner: Found to be clean X-MailScanner-From: grupos@carvalhaes.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.815 tagged_above=0 required=5 tests=HTML_50_60, HTML_MESSAGE, HTML_TEXT_AFTER_BODY, HTML_TITLE_EMPTY, MIME_HTML_ONLY, SUBJ_ALL_CAPS X-Spam-Level: * X-Archive-Number: 200504/378 X-Sequence-Number: 21271
Hi Guys!

I need to make an UPDATE on a column reordering it with a sequence using order by a description.
Confusing??? Well.. Let me give an example...

Today, my table it's organized like this:

Code     / Description
9          Orange
15         Apple
1          Pear
3          Tomato

I wanna to reorganize (reordering the code from 1 to ... ordering by description)

Code     / Description
1          Apple
2          Orange
3          Pear
4          Tomato


I created a sequence but I am having no succes to use it because UPDATE don't accept ORDER BY CLAUSE. The "ideal SQL" is UPDATE table SET code = nextval('sequence') ORDER BY description

I searched a lot on the NET without ant "tip" for my case.
It's a very simple need but I am not able to solve it...

Anyone knows how I can do it?

Cheers,

--
Rodrigo Carvalhaes


--
Esta mensagem foi verificada pelo sistema de antivírus e
acredita-se estar livre de perigo.