From: Richard Huxton <dev@archonet.com>
To: iuri de araujo sampaio <iuri.sampaio@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sintax error
Date: Fri, 19 Feb 2010 10:56:07 +0000
Message-ID: <4B7E6E47.5020503@archonet.com> (raw)
In-Reply-To: <4B7E4331.1050308@gmail.com>
References: <4B7E4331.1050308@gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, iuri.sampaio@gmail.com
Subject: Re: sintax error
In-Reply-To: <4B7E6E47.5020503@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox