Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1B0DC9F95A9 for ; Mon, 13 Aug 2007 16:29:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 28242-04 for ; Mon, 13 Aug 2007 16:29:52 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 1FA679F94EB for ; Mon, 13 Aug 2007 16:29:53 -0300 (ADT) Received: (qmail 9113 invoked by uid 0); 13 Aug 2007 19:29:52 -0000 Received: from 84.75.95.14 by www144.gmx.net with HTTP; Mon, 13 Aug 2007 21:29:52 +0200 (CEST) Content-Type: text/plain; charset="us-ascii" Date: Mon, 13 Aug 2007 21:29:52 +0200 From: "Christian Kindler" Message-ID: <20070813192952.76820@gmx.net> MIME-Version: 1.0 Subject: how to moce back in refcursor To: pgsql-sql@postgresql.org X-Authenticated: #27759442 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1/Qb48Sz67Qs1sjkhqJ8F+uIIB0ri3aLnWitnNUN7 KDy/5sHA+lLomDb51z/WywH1xjEXfPkE8NGA== Content-Transfer-Encoding: 7bit X-GMX-UID: CIb1cndZTiE+XCHywGVwqdV9ZUVSRFdB X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.336 tagged_above=0 required=5 tests=AWL=0.335, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/110 X-Sequence-Number: 29048 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 this sample 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 to declare 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