Re: Strange error with Pl/PgSQL - Mailing list pgsql-novice

From Tom Lane
Subject Re: Strange error with Pl/PgSQL
Date
Msg-id 685.975171046@sss.pgh.pa.us
Whole thread Raw
In response to Strange error with Pl/PgSQL  (Laurent HERVE <laurent_herve@infonie.fr>)
List pgsql-novice
Laurent HERVE <laurent_herve@infonie.fr> writes:
> create function TEST (char(5),char(6),char(11))
> returns boolean
> as '
> DECLARE
>         bank alias for $1;
>         guichet alias for $2;
>         compte alias for $3;
          ^^^^^^
>         cmpt record;
> BEGIN
> raise notice ''Banque %'',bank;
>                 select into cmpt * from compte;
                                          ^^^^^^
>                 return ''t'';
> END;'
> LANGUAGE 'plpgsql';

> ERROR:  parser: parse error at or near "$1"

> It doesn't happen with another table than ''compte''.

You've used compte as the name of a parameter in the function,
so the SELECT gets transformed to
                 select into cmpt * from $3;
which won't work.  (Although I'd have expected the error message
to complain about $3 not $1 ... hmm ... maybe something else is
going on here?)

            regards, tom lane

pgsql-novice by date:

Previous
From: Laurent HERVE
Date:
Subject: Strange error with Pl/PgSQL
Next
From: GH
Date:
Subject: Releasing locks