Re: Strange error with Pl/PgSQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurent HERVE <laurent_herve(at)infonie(dot)fr>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Strange error with Pl/PgSQL
Date: 2000-11-25 16:50:46
Message-ID: 685.975171046@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Laurent HERVE <laurent_herve(at)infonie(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message GH 2000-11-25 21:29:35 Releasing locks
Previous Message Laurent HERVE 2000-11-25 13:08:54 Strange error with Pl/PgSQL