Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 364326341A6 for ; Fri, 19 Feb 2010 06:58:22 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 88440-04-3 for ; Fri, 19 Feb 2010 10:58:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay.pcl-ipout01.plus.net (relay.pcl-ipout01.plus.net [212.159.7.99]) by mail.postgresql.org (Postfix) with ESMTP id 73F1E633957 for ; Fri, 19 Feb 2010 06:57:53 -0400 (AST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEABj9fUvUnw4U/2dsb2JhbACbB3S8VIRnBA Received: from pih-relay08.plus.net ([212.159.14.20]) by relay.pcl-ipout01.plus.net with ESMTP; 19 Feb 2010 10:56:08 +0000 Received: from [84.51.143.99] (helo=server3.office.archonet.com) by pih-relay08.plus.net with esmtp (Exim) id 1NiQWm-0004jc-2p; Fri, 19 Feb 2010 10:56:08 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTPA id C1CDB2740D6; Fri, 19 Feb 2010 10:56:07 +0000 (GMT) Message-ID: <4B7E6E47.5020503@archonet.com> Date: Fri, 19 Feb 2010 10:56:07 +0000 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9pre) Gecko/20100213 Lightning/1.0b1 Shredder/3.0.2pre MIME-Version: 1.0 To: iuri de araujo sampaio CC: pgsql-sql@postgresql.org Subject: Re: sintax error References: <4B7E4331.1050308@gmail.com> In-Reply-To: <4B7E4331.1050308@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: c58695b1f03dfccecb80b2019cbc994b X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/79 X-Sequence-Number: 33678 On 19/02/10 07:52, iuri de araujo sampaio wrote: > Hi there, > i have got the followed error in the pgsql function bellow. Log messages > point to: > > ******************** > ERROR: syntax error at end of input > LINE 1: SELECT > ^ > QUERY: SELECT > CONTEXT: SQL statement in PL/PgSQL function > "cms_permission__revoke_permission" near line 67 > > ********** Error ********** > > ERROR: syntax error at end of input > SQL state: 42601 > Context: SQL statement in PL/PgSQL function > "cms_permission__revoke_permission" near line 67 > > ******************** > > However, I couldn't find any sintax error in those SELECT statements > does anyone have any idea what is wrong with it? I thought it was the PERFORM statements, but it's not. The line number seems right, although the error message is misleading. > if v_count < 1 then > return; > end if; That bare return isn't legal. Try "return NULL" instead. The "error at end of input" means it was looking for an expression to return and couldn't find one. Oh - unrelated tips. 1. You can have multi-line comments with /* ... */ - very useful for debugging. 2. Any version of PostgreSQL from the last few years supports "dollar quoting". http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS That lets you do: create or replace function ... as $$ ... IF myvar = 'normal-quoting works here' THEN ... $$ language plpgsql; -- Richard Huxton Archonet Ltd