Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A0D236336B3 for ; Tue, 7 Apr 2009 13:08:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36723-03 for ; Tue, 7 Apr 2009 13:08:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 9F2B46330A6 for ; Tue, 7 Apr 2009 13:08:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n37G8DOu016187; Tue, 7 Apr 2009 12:08:13 -0400 (EDT) To: Matthew Wakeling cc: justin , pgsql-performance@postgresql.org Subject: Re: plpgsql arrays In-reply-to: References: <28757.1238767715@sss.pgh.pa.us> <49DB700F.8020108@emproshunts.com> Comments: In-reply-to Matthew Wakeling message dated "Tue, 07 Apr 2009 16:33:30 +0100" Date: Tue, 07 Apr 2009 12:08:13 -0400 Message-ID: <16186.1239120493@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/143 X-Sequence-Number: 33510 Matthew Wakeling writes: > CREATE OR REPLACE FUNCTION overlap_gene_primer() RETURNS SETOF RECORD AS $$ > DECLARE > left location; > retval RECORD; > BEGIN > DECLARE left_cursor NO SCROLL CURSOR FOR SELECT location FROM location, gene WHERE location.id = gene.id ORDER BY objectid, start, end; > left = FETCH left_cursor; > END; > $$ LANGUAGE plpgsql; Well, the DECLARE for the cursor should go in the DECLARE section, and the syntax for the FETCH should be FETCH cursorname INTO recordvariablename; and I'm too lazy to check right now but I think you might be missing an OPEN for the cursor. regards, tom lane