Received: from orion.SAPserv.Hamburg.dsh.de (Tpolaris2.sapham.debis.de [53.2.131.8]) by hub.org (8.9.3/8.9.3) with SMTP id NAA46925 for ; Mon, 8 Nov 1999 13:04:56 -0500 (EST) (envelope-from wieck@debis.com) Received: by orion.SAPserv.Hamburg.dsh.de for pgsql-sql@postgreSQL.org id m11kt2O-0003kLC; Mon, 8 Nov 99 18:57 MET Message-Id: From: wieck@debis.com (Jan Wieck) Subject: Re: [SQL] Declare Cursor... To: ulu@bornova.ege.edu.tr (Baris Ulu) Date: Mon, 8 Nov 1999 18:57:04 +0100 (MET) Cc: pgsql-sql@postgreSQL.org, maillist@candle.pha.pa.us (Bruce Momjian) Reply-To: wieck@debis.com (Jan Wieck) In-Reply-To: from "Baris Ulu" at Nov 8, 99 05:32:22 pm X-Mailer: ELM [version 2.4 PL25] Content-Type: text 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@debis.com (Jan Wieck) #