pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
refcursor
6+ messages / 6 participants
[nested] [flat]

* refcursor
@ 2003-01-05 10:11  Oliver Vecernik <vecernik@aon.at>
  0 siblings, 1 reply; 6+ messages in thread

From: Oliver Vecernik @ 2003-01-05 10:11 UTC (permalink / raw)
  To: pgsql-general

Hi!

I'm playing with refcursor, but I'm not successful. I defined follwing 
function:

CREATE OR REPLACE FUNCTION stat() RETURNS refcursor AS '
DECLARE
    ref refcursor;
BEGIN
    OPEN ref FOR
        SELECT * FROM tagebuch;
    RETURN ref;
END;
' LANGUAGE 'plpgsql';

Trying to see some results gives me:

sport=# select stat();
ERROR:  fmgr_info: function 16556: cache lookup failed
sport=# select version();
                            version                            
---------------------------------------------------------------
 PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4
(1 row)
sport=# select * from tagebuch;
...

This works fine. I receive the same error when I try to call stat() from Python with pyPgSQL-DBI adaptor. What am I doing wrong (PostgreSQL runs on a Debian/Woody box)?

Regards,
Oliver

-- 
VECERNIK Datenerfassungssysteme
A-2560 Hernstein, Hofkogelgasse 17
Tel.: +43 2633 47530, Fax: DW 50
http://members.aon.at/vecernik





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: refcursor
@ 2003-01-06 20:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Oliver Vecernik <vecernik@aon.at>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2003-01-06 20:09 UTC (permalink / raw)
  To: Oliver Vecernik <vecernik@aon.at>; +Cc: pgsql-general

>> sport=# select stat();
>> ERROR:  fmgr_info: function 16556: cache lookup failed

Does *any* plpgsql function work?  I think you probably broke plpgsql by
deleting its handler function, or something like that.  Try dropping and
recreating the plpgsql language (then you'll need to recreate your
function, too).

7.3 contains interlocks to prevent this sort of mistake, btw.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* refcursor
@ 2008-09-01 14:31  mike stanton <mstanton@acsa.cl>
  0 siblings, 1 reply; 6+ messages in thread

From: mike stanton @ 2008-09-01 14:31 UTC (permalink / raw)
  To: pgsql-general; +Cc: mstanton@acsa.cl


Hello all,
I've got a problem I can't get round. I want to declare a refcursor variable in a  C program and call a function which returns a refcursor portal to the main C program.
When I compile the C program, I get a refcursor doesn´t exist message. Has anyone got a  C program which uses a refcursor variable?
Hope you can help.

Cheers
Mike Stanton, Santiago Chile




Michael Stanton W.
Depto. Informática

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: refcursor
@ 2008-09-01 15:52  Alvaro Herrera <alvherre@commandprompt.com>
  parent: mike stanton <mstanton@acsa.cl>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2008-09-01 15:52 UTC (permalink / raw)
  To: mike stanton <mstanton@acsa.cl>; +Cc: pgsql-general

mike stanton escribió:
> 
> Hello all,
> I've got a problem I can't get round. I want to declare a refcursor variable in a  C program and call a function which returns a refcursor portal to the main C program.
> When I compile the C program, I get a refcursor doesn´t exist message.
> Has anyone got a  C program which uses a refcursor variable?

Make sure the C program opens a transaction before calling the function,
otherwise the cursor is automatically closed as soon as the function ends.

-- 
Alvaro Herrera	    Valdivia, Chile           Geotag: -39,815 -73,257
"Ah, spring... when a young penguin's fancy lightly turns to thoughts of ...
Beta testing!"                                  (Fedora 9 beta announcement)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Refcursor
@ 2021-03-15 11:58  Yambu <hyambu@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Yambu @ 2021-03-15 11:58 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

Hi

I new to cursors

May I know why the below takes so long?


BEGIN;
select * from func1() ;
fetch all from "<unnamed portal 1>";
end;

Select *  from func1() ;   on its own is very fast

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Refcursor
@ 2021-03-15 13:39  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Yambu <hyambu@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Laurenz Albe @ 2021-03-15 13:39 UTC (permalink / raw)
  To: Yambu <hyambu@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On Mon, 2021-03-15 at 13:58 +0200, Yambu wrote:
> May I know why the below takes so long?
> 
> 
> BEGIN; 
> select * from func1() ; 
> fetch all from "<unnamed portal 1>"; 
> end;  
> 
> Select *  from func1() ;   on its own is very fast

The second just fetches a cursor for the query, the
first executes the query.  Executing the query is what
can take long.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-03-15 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-05 10:11 refcursor Oliver Vecernik <vecernik@aon.at>
2003-01-06 20:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2008-09-01 14:31 refcursor mike stanton <mstanton@acsa.cl>
2008-09-01 15:52 ` Alvaro Herrera <alvherre@commandprompt.com>
2021-03-15 11:58 Refcursor Yambu <hyambu@gmail.com>
2021-03-15 13:39 ` Re: Refcursor Laurenz Albe <laurenz.albe@cybertec.at>

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