Fetching from psql procedures

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Fetching from psql procedures
Date: 2015-11-19 13:51:18
Message-ID: B6F6FD62F2624C4C9916AC0175D56D88420B5714@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm looking for a way to build large xml documents based on a set of tables, hence using recursive queries.

something like:

FOR rec1 IN ...
FOR rec2 IN ...

RETURN QUERY select '<foo>
FOR rec3 IN ...

RETURN QUERY select (XMLELEMENT (...))::text

END LOOP;
RETURN QUERY select '</foo>

END LOOP;
END LOOP;



but if I wrap this in a function, it seems that I won't get a result before the whole document is prepared.

Is there any way to stream the result as it get produced ?
or does anybody knows of a good tutotial for a task like this ?


thanks and best regards,

Marc Mamin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Day, David 2015-11-19 15:01:41 Re: postgres zeroization of dead tuples ? i.e scrubbing dead tuples with sensitive data.
Previous Message Roxanne Reid-Bennett 2015-11-19 07:26:55 Re: controlling memory management with regard to a specific query (or groups of connections)