Re: [SQL] Declare Cursor...

From: wieck(at)debis(dot)com (Jan Wieck)
To: ulu(at)bornova(dot)ege(dot)edu(dot)tr (Baris Ulu)
Cc: pgsql-sql(at)postgreSQL(dot)org, maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Subject: Re: [SQL] Declare Cursor...
Date: 1999-11-08 17:57:04
Message-ID: m11kt2O-0003kLC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Baris ULU wrote:

> I am trying to declare a cursor inside a plpgsql function in a
> begin end block as in the following:
> create function func_1(char, float8, int4, int4) returns int4 as '
> declare
> x alias for $1;
> y alias for $2;
> z alias for $3;
> t alias for $4;
> ...
> begin work;
> declare cursor_x cursor for select a, b, c, d from table_1 where a = x;
> ...
> end work;
>
> when this function is compiled, it gives me the following error:
> NOTICE: plpgsql: ERROR during compile of func_1 near line ...
> ERROR: parse error at or near "CURSOR"
>
> If anyone can help me about my problem, I will be very happy...THANKS!

Backend functions cannot use cursors. This is not supported
by the underlying mechanism of portals and the server
programming interface.

Yes, it's a very bad limitation since the SPI tries to load
the entire result set into memory, possibly blowing away the
backend process. I don't know how and when we will tackle
this, but it should go onto the TODO, Bruce.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Matlack, Brad 1999-11-08 20:06:23 newbie outer-join
Previous Message Oskar Liljeblad 1999-11-08 17:19:46 about the subselect query