pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedOutput of function into a file
3+ messages / 3 participants
[nested] [flat]
* Output of function into a file
@ 2002-11-09 05:30 karthick v <karthickv@hclp.com>
2002-11-12 18:48 ` Re: [SQL] Output of function into a file Rajesh Kumar Mallah. <mallah@trade-india.com>
0 siblings, 1 reply; 3+ messages in thread
From: karthickv@hclp.com @ 2002-11-09 05:30 UTC (permalink / raw)
To: pgsql-general@postgresql.org; pgsql-sql
Hi,
I am writing a small function to manipulate records in multiple
tables. Since the function cannot return more than one value, I would
like to get all the outputs of the queries and append them into a text
file.
Is there any way to do it inside the function. I came across many
postings which tell me how to use it in pgsql but not inside the
function.
I would be very glad if someone could help me
Thanks in advance
karthick v
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] Output of function into a file
2002-11-09 05:30 Output of function into a file karthick v <karthickv@hclp.com>
@ 2002-11-12 18:48 ` Rajesh Kumar Mallah. <mallah@trade-india.com>
0 siblings, 0 replies; 3+ messages in thread
From: Rajesh Kumar Mallah. @ 2002-11-12 18:48 UTC (permalink / raw)
To: karthickv@hclp.com; pgsql-general@postgresql.org; pgsql-sql
in 7.3 you will be able to return multiple rows
with multiple columns.
7.3 stable is going to be out soon as it in beta 5 stage
currently.
regds
mallah.
On Saturday 09 November 2002 11:00, karthick v wrote:
> Hi,
>
> I am writing a small function to manipulate records in multiple
> tables. Since the function cannot return more than one value, I would
> like to get all the outputs of the queries and append them into a text
> file.
>
> Is there any way to do it inside the function. I came across many
> postings which tell me how to use it in pgsql but not inside the
> function.
>
> I would be very glad if someone could help me
>
> Thanks in advance
>
> karthick v
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)
Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Output of function into a file
@ 2002-11-12 14:37 Christoph Haller <ch@rodos.fzk.de>
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Haller @ 2002-11-12 14:37 UTC (permalink / raw)
To: karthickv@hclp.com; +Cc: pgsql-sql
>
> I am writing a small function to manipulate records in multiple
> tables. Since the function cannot return more than one value, I would
> like to get all the outputs of the queries and append them into a text
> file.
>
> Is there any way to do it inside the function. I came across many
> postings which tell me how to use it in pgsql but not inside the
> function.
>
You did not tell which function language you're talking about.
I'm assuming it's plpgsql.
First, did you check the cursors section?
Rather than executing a whole query at once, it is possible to set up a
cursor that encapsulates the query, and then read the query
result a few rows at a time. One reason for doing this is to avoid
memory overrun when the result contains a large number of rows.
(However, PL/pgSQL users don't normally need to worry about that, since
FOR loops automatically use a cursor internally to avoid
memory problems.) A more interesting possibility is that a function can
return a reference to a cursor that it has set up, allowing
the caller to read the rows. This provides one way of returning a rowset
from a function.
Taken from "PostgreSQL 7.2.1 Documentation Chapter 23. PL/pgSQL - SQL
Procedural Language"
Second, if this is not what you want to use,
I have not seen anything within plpgsql which could be used
to write to a file. But, what about a database table to be used as a
file?
e.g.
CREATE TABLE file_replacement(one_line TEXT);
then populate it by inserts like
INSERT INTO file_replacement VALUES('<one-row-of-your-query-result>');
and to get them back in FIFO order
SELECT one_line FROM file_replacement ORDER BY oid;
Regards, Christoph
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-11-12 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-09 05:30 Output of function into a file karthick v <karthickv@hclp.com>
2002-11-12 18:48 ` Rajesh Kumar Mallah. <mallah@trade-india.com>
2002-11-12 14:37 Re: Output of function into a file Christoph Haller <ch@rodos.fzk.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox