Re: How iterate records

From: Richard Huxton <dev(at)archonet(dot)com>
To: Jan Poslusny <pajout(at)gingerall(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How iterate records
Date: 2005-02-22 11:34:24
Message-ID: 421B18C0.9060601@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jan Poslusny wrote:
> Hi,
> I have a problem of plpgsql usage. When I iterate through dynamic query,
> like this:
>
> FOR my_/record/ IN EXECUTE /text_expression/ LOOP /statements/
> END LOOP;
>
> I am not able to construct expression, which can get value for each
> 'item' of my_record, something like my_record[3] or get_item(my_record,
> 3), without knowledge about real names of record pieces. I know that it
> is not the goal of this language, but my goal is to implement some lite
> functions returning XML rather then something else...

You'll need to use another language. As you say, plpgsql isn't designed
for this sort of thing, and it's not clear how you would handle
different types as you iterated over row attributes.

Try pltcl or plperl (or python I'd have thought) - they're much more
suited to this sort of thing.

PS - IMHO, formatting data into XML is a client-side task, middle-ware
probably.
--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-02-22 11:39:06 Re: Off-topic: monograph for database postgraduate
Previous Message Dorian Büttner 2005-02-22 11:27:32 psql terminal / quote-key