Re: rows and array - Mailing list pgsql-general

From FERREIRA William (COFRAMI)
Subject Re: rows and array
Date
Msg-id 1904E3EB39448246A7ECB76DF34A70B00143B443@TOCOMEXC03
Whole thread Raw
In response to rows and array  ("FERREIRA William (COFRAMI)" <william.ferreira@airbus.com>)
List pgsql-general

i don't want to do the re-ordering on the client side.
i want a stored procedure which extract some rows from a database into an array.
next i have a function for re-ordering the array depending on specific needs
and finally generate a XML file on the server

-----Message d'origine-----
De : pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]De la part de Tom Lane
Envoyé : mardi 22 février 2005 16:29
À : Richard Huxton
Cc : FERREIRA William (COFRAMI); 'pgsql-general@postgresql.org'
Objet : Re: [GENERAL] rows and array

Richard Huxton <dev@archonet.com> writes:
> FERREIRA William (COFRAMI) wrote:
>> i can store rows and re-order them like this :
>> children(i-j) := children(i-j-1);

> Well, I'd look at one of three solutions:
>   1. Functional index to order by
>   2. Temporary table (read up on EXECUTE and OID caching)
>   3. pl/perl/python (which are better suited to this sort of thing)

I think what he's saying is he wants to do the re-ordering on the client
side.  This seems trivial enough.  If I were doing it against a libpq
result set, I'd probably not bother to sort the physical rows; I'd just
make an array of integers representing row numbers in the PGresult and
sort the row numbers, then use those numbers to pull out the fields when
it came time to display 'em.  (Another way to say that is that a
PGresult *is* an array, it's just got a funny access syntax.)

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.

pgsql-general by date:

Previous
From: Phil Endecott
Date:
Subject: Re: Triggers, again.. ;-)
Next
From: Tom Lane
Date:
Subject: Re: Triggers, again.. ;-)