agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: Function Issue!
Date: Wed, 18 Aug 2004 21:36:09 -0400
Message-ID: <6771.1092879369@sss.pgh.pa.us> (raw)
In-Reply-To: <82E30406384FFB44AFD1012BAB230B55037D051E@shiva.au.lpint.net>
References: <82E30406384FFB44AFD1012BAB230B55037D051E@shiva.au.lpint.net>
Theo Galanakis <Theo.Galanakis@lonelyplanet.com.au> writes:
> Can anyone tell me what is wrong with the function below ?
> CREATE OR REPLACE FUNCTION "public"."theo_test2" () RETURNS OPAQUE AS'
> BEGIN
> declare curr_theo cursor for select * from node_names;
> fetch next from curr_theo;
> close curr_theo;
> END;
> 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY DEFINER;
The DECLARE has to go before the BEGIN:
CREATE OR REPLACE FUNCTION "public"."theo_test2" () RETURNS OPAQUE AS'
DECLARE
curr_theo cursor for select * from node_names;
BEGIN
fetch next from curr_theo;
close curr_theo;
END;
'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY DEFINER;
I think you are missing an OPEN step too, and the FETCH syntax is wrong
for plpgsql. Read the plpgsql doc section about using cursors --- it
is not at all identical to what you do in plain SQL.
regards, tom lane
view thread (7+ messages) latest in thread
Message-ID: <6771.1092879369@sss.pgh.pa.us>
Permalink: ../6771.1092879369@sss.pgh.pa.us/
Also on: postgresql.org/message-id/6771.1092879369@sss.pgh.pa.us
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, Theo.Galanakis@lonelyplanet.com.au
Subject: Re: Function Issue!
In-Reply-To: <6771.1092879369@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox