Re: sintax error

From: Richard Huxton <dev(at)archonet(dot)com>
To: iuri de araujo sampaio <iuri(dot)sampaio(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sintax error
Date: 2010-02-19 10:56:07
Message-ID: 4B7E6E47.5020503@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

  • sintax error at 2010-02-19 07:52:17 from iuri de araujo sampaio

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gordon Ross 2010-02-19 10:58:24 Re: Unable to get UPDATE ... FROM syntax correct
Previous Message Richard Huxton 2010-02-19 10:36:21 Re: Unable to get UPDATE ... FROM syntax correct