Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 786BC2E01EF for ; Thu, 6 Mar 2008 04:24:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 51068-05 for ; Thu, 6 Mar 2008 04:24:50 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pih-relay08.plus.net (pih-relay08.plus.net [212.159.14.134]) by postgresql.org (Postfix) with ESMTP id 59C652E01EB for ; Thu, 6 Mar 2008 04:24:53 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1JXBPH-0004XJ-Ed; Thu, 06 Mar 2008 08:24:51 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 2D1B5274060; Thu, 6 Mar 2008 08:24:51 +0000 (GMT) Message-ID: <47CFAA53.7010309@archonet.com> Date: Thu, 06 Mar 2008 08:24:51 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: Yura Gal CC: pgsql-sql@postgresql.org Subject: Re: RETURN QUERY generates error References: <3b6c69d80803052345g31af3b74k6b8878c65197d621@mail.gmail.com> In-Reply-To: <3b6c69d80803052345g31af3b74k6b8878c65197d621@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 86e121624e88fb73939d7e80a6acb290 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/24 X-Sequence-Number: 30352 Yura Gal wrote: > > IF _byblocks IS TRUE THEN > RETURN QUERY SELECT > regexp_split_to_table(array_to_string(_sequence, ','), E','); > ELSE > RETURN QUERY SELECT array_to_string(_sequence, ''); > END IF; > RETURN; > END; > $body$ > LANGUAGE 'plpgsql' IMMUTABLE CALLED ON NULL INPUT SECURITY INVOKER; > > all is fine until the last IF. Both RETURN QUERY blocks generate > error: 'syntax error at or near SELECT ...' I feel that something > wrong with casting _sequence var but I can't figure out the exact > point. Can't think why it's not happy - if I create an empty table to go with it, it runs here. If you replace them with RETURN QUERY SELECT '' does that make the error go away? Oh, and are you sure you mean IMMUTABLE? That's only true if hg18.genome is a static table. -- Richard Huxton Archonet Ltd