Thread: how to moce back in refcursor
Hi I have never worked with cursors but for now I have to step back on special events to calculate a difference. So I have thissample code tested but I can not "move" in my cursor. I have lokke at docs but this didn't help me. Can you say how todeclare my cursor to step back? Thank You Chris PS code sample create table fimi.eodbar(fi_id int8, market_id int8); insert into fimi.eodbar values(322,200); create or replace function fimi.test("fiid" int8) returns setof int as $BODY$ DECLARE cur1 REFCURSOR; foo int; BEGIN OPEN cur1 FOR execute('select market_id from fimi.eodbar where fi_id=' || "fiid"); loop fetch cur1 into foo; if not found then exit ; else -- move -1 in cur1; fetch cur1 into foo; return next foo; end if; end loop; close cur1; END; $BODY$ LANGUAGE 'plpgsql' VOLATILE; ALTER FUNCTION fimi.getfoo(bpchar) OWNER TO fimi; select * from fimi.test(322); -- cu Chris GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
"Christian Kindler" <christian.kindler@gmx.net> writes: > -- move -1 in cur1; plpgsql supports that in CVS HEAD (8.3-to-be) but not in any existing release. You'll need to rethink your logic or do this from your application rather than within plpgsql. regards, tom lane
Oh I see .... But damn I need it in plpgsql because all my Application logic is delevoped in the backend. Ok maybe I canwork around this. Thank you very much! Chris -------- Original-Nachricht -------- Datum: Mon, 13 Aug 2007 15:55:40 -0400 Von: Tom Lane <tgl@sss.pgh.pa.us> An: "Christian Kindler" <christian.kindler@gmx.net> CC: pgsql-sql@postgresql.org Betreff: Re: [SQL] how to moce back in refcursor > "Christian Kindler" <christian.kindler@gmx.net> writes: > > -- move -1 in cur1; > > plpgsql supports that in CVS HEAD (8.3-to-be) but not in any existing > release. You'll need to rethink your logic or do this from your > application rather than within plpgsql. > > regards, tom lane -- cu Chris Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser