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

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to