Cursor Example Needed - Mailing list pgsql-general

From Perry Smith
Subject Cursor Example Needed
Date
Msg-id 194640B3-4F22-47C4-8E38-7DCCEF958EAD@gmail.com
Whole thread Raw
Responses Re: Cursor Example Needed  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
When I execute the SELECT statement directly I get:

psql:table.sql:28: out of memory for query result

I've read the way around this is to use cursors.  So I read and I see that I can use a FOR statement but I need that
insidea function. 

So far, I've come up with this:

> CREATE OR REPLACE FUNCTION blah() RETURNS integer AS $$
>
> DECLARE
>   xyz CURSOR FOR SELECT * FROM shipped_files WHERE aix_file = '/usr/lib/drivers/vioentdd' AND service_pack =
'7100-01-06';
>
> BEGIN
>   FOR my_rec IN xyz LOOP
>     -- xyxyxy what to do where? xyxyxy  These things don't work:
>     COPY ( my_rec ) TO stdout;
>     SELECT * FROM my_rec;
>     etc.
>   END LOOP;
>
>   RETURN 5;
> END
> $$ LANGUAGE plpgsql;
>
> SELECT * FROM blah();

I just want to output the rows being selected as text.  Basically I want the same output that the SELECT statement
wouldproduce if it didn't fail. 

Also, what should I do with the SELECT * FROM blah() statement?  I'm doing that just to get blah() to execute.  I have
afeeling I'm way far off base. 

Thank you,
Perry


Attachment

pgsql-general by date:

Previous
From: Steve Crawford
Date:
Subject: Re: Table partitioning
Next
From: "Herouth Maoz"
Date:
Subject: Re: Table partitioning