From: | SunMie Won <sunmiewon(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | using CURSORS within a function |
Date: | 2001-11-16 18:18:36 |
Message-ID: | 20011116181836.84697.qmail@web11102.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Any tips on how to use a cursor within a function?
Does the DECLARE come after the BEGIN ( as all the
documentation suggests) or in the typical place for
declarations (after AS and before BEGIN). I have tried
both places and when running the function, get the
following error:
ERROR: parse error at or near CURSOR
Below is the syntax for my function:
CREATE FUNCTION "fnc_testcursor"("int4") RETURNS
"int4" AS
'DECLARE c_seating CURSOR FOR SELECT id_seat FROM
tbl_seating WHERE id_order = 0;
BEGIN FETCH 1 FROM c_seating;
CLOSE c_seating;
END;'
LANGUAGE 'plpgsql';
OR version 2:
CREATE FUNCTION "fnc_testcursor"("int4") RETURNS
"int4"
AS
'
BEGIN
DECLARE c_seating CURSOR FOR SELECT id_seat FROM
tbl_seating WHERE id_order = 0;
FETCH 1 FROM c_seating;
CLOSE c_seating;
END;'
LANGUAGE 'plpgsql';
Both functions return the same error when called.
Thanks in advance-
SunMie Won
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Shane Wegner | 2001-11-16 23:36:12 | Unsigned types |
Previous Message | Aasmund Midttun Godal | 2001-11-16 17:30:19 | Re: pgsql and large tables |